Exceptions: Difference between revisions

(Added Dyalect)
Line 858:
 
<lang dyalect>func Integer.Add(x) {
throw Error.@NegativesNotAllowed(x) when x < 0
this + x
}
 
try {
12.Add(-5)
} catch {
@NegativesNotAllowed(x) => print("Negative number: \(x)")
}</lang>
 
 
=={{header|DWScript}}==
Anonymous user