main int[] iv // Let's assign to an invalid position try iv[5] = 13 catch Throwable t print "Catched" // Prints "Catched" // Let's continue //...
Exceptions are used for error handling in Origo.
There are two main types of exceptions in Origo as depicted in the figure below.
| Throwable | FatalError |
|---|---|
| Abstract base class Examples: - VMNullPointerException - VMIndexOutOfBoundsException - VMDivisionByZeroException - VMStringException - VMRangeException | Examples: - Bytecode corrupt - Out of memory - Stack underflow |
Throwable serves as an abstract base class for compile time and runtime exceptions, that can be caught using try - catch - finally blocks.
main int[] iv // Let's assign to an invalid position try iv[5] = 13 catch Throwable t print "Catched" // Prints "Catched" // Let's continue //...
All exceptions are associated with a string type message. Exception, Error and FatalError can be inherited using extend specifier.
| Exception | RunTimeException |
|---|---|
| Must be caught Subclasses | ArrayIndexOutOfBounds MalformedUrl MalformedRegularExperession Null pointer dereference Division by zero Class cast exception |