Difference between revisions of "Exception Handling"
(Created page with "=Exception Handling (Error Runtime Handling)= category:CGScript __NOTOC__") |
|||
Line 2: | Line 2: | ||
[[category:CGScript]] | [[category:CGScript]] | ||
__NOTOC__ | __NOTOC__ | ||
+ | |||
+ | An exception is an error occurs in the runtime (the excution) of program. The CGScript languages use the '''try/catch statement''' and the '''throw''' expression to implement the exception handling. | ||
+ | |||
+ | == <span style="color:#a52a2a;">'''Syntax'''</span> == | ||
+ | === try-catch statement === | ||
+ | try { | ||
+ | // codes that could throw an exception | ||
+ | } | ||
+ | catch (exception-declaration) { | ||
+ | // codes that execute when exception-declaration is thrown in the try block | ||
+ | } | ||
+ | [catch (exception-declaration) { | ||
+ | // code that handles another exception type | ||
+ | } ] . . . ] | ||
+ | |||
+ | === throw expression === | ||
+ | throw [expression] | ||
+ | |||
+ | |||
+ | == <span style="color:#a52a2a;">'''Examples'''</span> == |
Revision as of 11:49, 19 December 2011
Exception Handling (Error Runtime Handling)
An exception is an error occurs in the runtime (the excution) of program. The CGScript languages use 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-declaration) {
// codes that execute when exception-declaration is thrown in the try block
} [catch (exception-declaration) {
// code that handles another exception type
} ] . . . ]
throw expression
throw [expression]