Content deleted Content added
add exception handling syntax for ooRexx Tags: Reverted Visual edit |
No edit summary Tags: Mobile edit Mobile app edit iOS app edit App section source |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 207:
try {
// do something (might throw an exception)
} catch (const std::runtime_error e) {
// handle a runtime_error e
} catch (const std::exception& e) {
//
} catch (...) {
// catches all
}
}
Line 268 ⟶ 269:
try {
// code which could result in an exception
} catch (any e){
retry;
Line 493:
// Statements in which exceptions might be thrown
throw new Error("error");
} catch (error) {
// Statements that execute in the event of an exception
} finally {
Line 511:
try {
throw 12345; // primitive number
} catch (error) {
console.log(error); // logs 12345 as a primitive number to the console
}
Line 520:
// Example in Java
try {
Integer i = null;
i.intValue(); // throws a NullPointerException
} catch (NullPointerException error) {
// Variable might be null
} catch (ArithmeticException error) {
// Handle problems with numbers
}
</syntaxhighlight>
Line 534:
var example = null;
example.toString();
} catch (error) {
if (error.type === "TypeError") {
// Variable might be null
Line 549:
var example = null;
example.toString();
} catch (error) {
if (error.type !== "TypeError") throw error;
// Variable might be null
}
} catch (error) {
if (error.type !== "RangeError") throw error;
// Handle problems with numbers
Line 586:
obj.selfPropExample = obj; // circular reference
throw obj;
} catch (error) {
// Statements that execute in the event of an exception
}
</syntaxhighlight>▼
{{Further|Kotlin (programming language)}}
try {
// Code that may throw an exception
} catch (e: SomeException) {
// Code for handling the exception
}
</syntaxhighlight>
Line 768 ⟶ 778:
Printexc.record_backtrace true
or by setting the environment variable OCAMLRUNPARAM="b1"*)
▲</syntaxhighlight>
▲=== ooRexx ===
▲<syntaxhighlight lang="rexx">
</syntaxhighlight>
|