BBj Object Error Handling
Description
BBj allows object expressions to be used anywhere in the language. It does not attempt to do type checking until runtime. For example, assuming that NUM!=123 and STR!="123", all of the following statements are accepted as valid syntax, but all generate errors at runtime:
|
The STR() function can be used to convert a numeric or string object expression to a string. For example:
|
Similarly, the NUM() function can be used to convert a numeric or string object expression to a number. For example:
|
The ERR= option can be used in the NUM() function if there is any chance that a conversion error might occur. The STR() function will never generate a conversion error, but it also allows the ERR= option for syntactic completeness.
The ERR= option can also be used to trap errors from Java calls. For example, the following code fragment will loop until the user enters a valid binary number:
|
The ERR= option is allowed at the end of the argument list of any Java constructor or method call. Some examples are:
|
If embedded Java code throws
an exception, BBj will catch that exception and will generate !ERROR=252.
The exception information can be retrieved with:
E!=BBjAPI().getLastException()
E! is a java.lang.Throwable
object; see the Java documentation for details.