Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Exception Handling: Difference between revisions

From Catglobe Wiki
Tungocman (talk | contribs)
No edit summary
Tungocman (talk | contribs)
Line 7: Line 7:
== <span style="color:#a52a2a;">'''Syntax'''</span>  ==
== <span style="color:#a52a2a;">'''Syntax'''</span>  ==
=== try-catch statement ===
=== try-catch statement ===
<pre>
try {
try {
   // codes that could throw an exception
   // codes that could throw an exception
Line 16: Line 17:
   // code that handles another exception type
   // code that handles another exception type
} ] . . . ]
} ] . . . ]
</pre>


=== throw expression ===
=== throw expression ===

Revision as of 10:50, 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]


Examples