> FrAid
 

Error Handling in FrAid

Error Handling in FrAid scripts

Right now it is pretty much up to you. You can return a number which means something, like 0 = success, everything else is some sort of error code:

                Success = 0;
                ArgumentShouldBeString = 1;

                myFun(x) = if isString(x)
                then Success & myStringArgumentFunction(x)
                else ArgumentShouldBeString;
            

or you can return an error message (if you return a string it automatically gets printed on the out stream):

                myFun(x) = if isString(x)
                then "Success " + myStringArgumentFunction(x)
                else "Argument Should Be String!";
            

Ability to write to the err stream will be added soon.

Note
You need the next section only if you use FrAid from Java.

Error Handling from Java

Most FrAid packages define their own exceptions (i.e. org.fraid.plugin has PluginException, org.fraid.complex has ComplexFunctionException, etc. ) which you can use in the particular context. This rule is not strict though. You can use any exception declared to be thrown by a particular method (some times those declarations are pretty generous and this may have to change). The parser, org.fraid.interpreter defines its own exceptions. See Fraid.workWithConsole(...) for an example of how to recover after an exception in the parser.