Why does this program not do anything with throw? : <p><a href="https://i.stack.imgur.com/TGYPs.png" rel="nofollow noreferrer">enter image description here</a></p>

<p>I am reading some code online for a function and it has this throw-sentence. </p>

<p>I implemented the same function, but when I call it to make sure it throws (by making  x negative), my code doesn't work, because I am not "handling the exception".</p>

<p>But neither does the code in the picture, so what's going on here?</p>

<p>Basically what I am looking for is a function that gets called when somebody inputs bad arguments to a function, and then the function just halts the program and says "no you're doing it wrong". How do I do that? </p>

<p>I read online a bit about throw and catch and try and all that, but really, I don't want to do that. I just want ONE thing to halt the program once it sences something is wrong.</p>
