Post Reply 
How do I raise a user-defined error?
04-20-2017, 10:51 PM
Post: #1
How do I raise a user-defined error?
Is there a way to generate a user-defined error in a Prime program that can be trapped using IFERR...THEN... ?

I could always use a 'divide by 0' to force an error but that won't be very intuitive for the user.
Find all posts by this user
Quote this message in a reply
04-21-2017, 09:01 AM
Post: #2
RE: How do I raise a user-defined error?
I think there is no way to trigger an user defined error but you are right, dividing by zero could be a way Smile

The error number is stored in Ans, so you could do something after the error is triggered.

My website: ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
04-21-2017, 02:05 PM (This post was last modified: 04-21-2017 02:07 PM by Han.)
Post: #3
RE: How do I raise a user-defined error?
In what sense do you mean "raise a user-defined error"? Do you already know that an error occurred at that point? If so, then a simple message box with the error string might do the job. On the other hand, if you want to generate an actual error, then your idea is likely the only way to generate an error in a controlled way. The error number is stored in Ans, but it will be useless if you forced a divide-by-0 error. You could, however, have your own errn and errmsg variable that you can set. Since you are forcing an error, then save your error number or string to an appropriate variable, generate the error, and use your variable for the error handling. It could be something as simple as return(errmsg) if you want the program to stop execution.

EDIT: It seems to me that you're eventual use of IFERR THEN END is merely to create a controlled break. Why not simply use an appropriate return()?

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: