Exceptions: Difference between revisions

m
Line 1,669:
It is also possible to create new exception classes (see Exception.of).
 
<lang Oforth>func: iwillThrowAnException { Exception throw("A new exception") }Exception throw ;
 
func: iwillCatch {
| e |
try: e [ iwillThrowAnException ] when: [ System.Out "Exception catched : " << e << cr ]
try: e [ 1 dup2 over last ] when: [ System.Out "Exception catched : " << e << cr ]
"Done" println ;</lang>
}</lang>
 
{{out}}
1,015

edits