Catching error messages

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Catching error messages

Catching error messages

by topsquark » Mon Oct 02, 2023 10:12 pm

I have occasionally seen lines of code that appear to catch errors and then the program alters the situation to deal with it, rather that let the error shut the code down.

Trouble is, when I search for where I saw it, I get just about every language but TikZ.

As a quick example of what I am trying to do, I'm making a projectile motion code and I want the code to catch if there's an error in the data, that the object will not reach the target. This would entail taking the square root of a negative number. Now, I don't have to get fancy: I can just calculate the discriminant and do an ifthenelse to stop the error before it happens. But if an error could be caught, it might be a useful debugging tactic to have handy.

A link to an example would probably be enough. I just need to see how to structure the code first. Then I can come back and ask any specific questions as needed. I'm just looking for a starting point.

Thanks!

-Dan

Top