Difference between revisions of "Exception Handling"
(→Syntax) |
(→Exception Handling (Error Runtime Handling)) |
||
Line 4: | Line 4: | ||
An exception is an error occurs in the runtime (the excution) of program. The CGScript language uses the '''try/catch statement''' and the '''throw''' expression to implement the exception handling. | An exception is an error occurs in the runtime (the excution) of program. The CGScript language uses the '''try/catch statement''' and the '''throw''' expression to implement the exception handling. | ||
+ | |||
== <span style="color:#a52a2a;">'''Syntax'''</span> == | == <span style="color:#a52a2a;">'''Syntax'''</span> == | ||
Line 14: | Line 15: | ||
// codes that execute when exception-declaration is thrown in the try block | // codes that execute when exception-declaration is thrown in the try block | ||
} | } | ||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
− | * The '''exception''' can be any | + | * The '''exception''' can be any type (E.g. exception object, number, string...) |
+ | * CGScript language does not support multi catch clauses. | ||
=== throw expression === | === throw expression === | ||
throw [expression] | throw [expression] | ||
− | * The '''expression''' can be any | + | * The '''expression''' can be any type (E.g. exception object, number, string...) |
− | * If throw is used | + | * If throw is used in catch clause, it will be re-throw. See below examples for information about re-throw. |
== <span style="color:#a52a2a;">'''Examples'''</span> == | == <span style="color:#a52a2a;">'''Examples'''</span> == |
Revision as of 04:36, 20 December 2011
Exception Handling (Error Runtime Handling)
An exception is an error occurs in the runtime (the excution) of program. The CGScript language uses the try/catch statement and the throw expression to implement the exception handling.
Syntax
try-catch statement
try { // codes that could throw an exception } catch (exception) { // codes that execute when exception-declaration is thrown in the try block }
- The exception can be any type (E.g. exception object, number, string...)
- CGScript language does not support multi catch clauses.
throw expression
throw [expression]
- The expression can be any type (E.g. exception object, number, string...)
- If throw is used in catch clause, it will be re-throw. See below examples for information about re-throw.