"on error"

"on error" - "on error" - Messages

#1 Posted: 1/27/2022 8:37:35 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

If the object does not exist in the scan ... I understand.
If > 10^307 ... if < 10^-307 ... I understand.
What else creates "on error" ?
MCD 11 and Smath often disagree.
In some instance, Smath "on error" must be coded otherwise.
Comments appreciated .... Cheers, Jean.
#2 Posted: 1/28/2022 9:53:00 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Hello Jean,

try/onerror is just a way to manage errors.

They happens because a lot of reasons (values too high, file I/O, operation on strings, mixed types on data sources, mixed units, bad user input, etc...) and you might expect some specific errors or some "possible, currently undefined" errors.

If you might want to handle them in a custom way other than the low-level error message, that is the function to do it.

For example you can use it to override results with some default value, or give some hint to change something; the use depends on the context, what are the input variables and what you expect to happen in case of a predictable or "unpredictable" error.

IDK if can be improved in some way, but is a common and very simple function in most programming languages (try-catch in C-style languages, try-except in Phyton, ...)

2022-01-28 13_39_04-SMath Solver - [Worksheet1_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Posted: 1/28/2022 12:11:21 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Thanks Davide, you are great Educator !
Take care ... Jean.
  • New Posts New Posts
  • No New Posts No New Posts