exception()
Used inside a catch block, this function returns a structure with fields: what, index, and value.
Example
f(x)={
y = "hello";
try {
switch(x) {
case 0: return 88;
case 1: x = x+y;
break;
case 2: throw("This is a user exception");
case 3: throw("This is a user exception", 788);
case 4: throw("This is a user exception", 789, y);
case 5: throw(3);
}
}
catch {
s = exception();
println("Caught exception: ", s.what, "\nIndex is ", s.index, " object is ", s.value);
return 99;
}
}
f(0)
88
f(1)
Caught exception: Binary operator "+" of a "integer" and a "string" is not implemented
Index is 0 object is void
99
f(2)
Caught exception: This is a user exception
Index is 0 object is void
99
f(3)
Caught exception: This is a user exception
Index is 788 object is void
99
f(4)
Caught exception: This is a user exception
Index is 789 object is hello
99
f(5)
Caught exception: Parameter number 1 passed to function "throw" is of type "integer".
It must be of type "string".
Index is 0 object is void
99