| File exception_demo.icn |
Demonstration of the exception package
Author: Steve Wampler (sbw@tapestry.tucson.az.us)
This file is in the public domain.
Demonstration of exception handling. A call with any numeric argument other than three runs without Exception. Any non-numeric argument throws a NumException (locally defined) while a call with the argument 3 throws an Exception (base class for all Exceptions).
The result of calling:
ExceptionDemo 1 2 3 4 a 6
is:
x is '1'.
x is '2'.
Exception: bad value of 3:
g [ExceptionDemo.icn:96]
f [ExceptionDemo.icn:80]
main [ExceptionDemo.icn:56]
x is '4'.
NumException: 'a' is not a number:
g [ExceptionDemo.icn:93]
f [ExceptionDemo.icn:80]
main [ExceptionDemo.icn:56]
x is '6'.
This file is part of the (main) package.
Source code.| Details |
| Procedures: |
i | - arbitrary value |
Simple function that outputs the result of another function. Used to show that exception handling is a true 'throw'.
i | - arbitrary value |
i if numeric(i) ~= 3 |
NumException | if argument is not numeric |
Exception | if argument is 3 |
Simple function that performs (meaningless) work but can throw two different types of Exceptions.