A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
20
Task/Exceptions/Fancy/exceptions.fancy
Normal file
20
Task/Exceptions/Fancy/exceptions.fancy
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# define custom exception class
|
||||
# StandardError is base class for all exception classes
|
||||
class MyError : StandardError {
|
||||
def initialize: message {
|
||||
# forward to StdError's initialize method
|
||||
super initialize: message
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
# raises/throws a new MyError exception within try-block
|
||||
MyError new: "my message" . raise!
|
||||
} catch MyError => e {
|
||||
# catch exception
|
||||
# this will print "my message"
|
||||
e message println
|
||||
} finally {
|
||||
# this will always be executed (as in e.g. Java)
|
||||
"This is how exception handling in Fancy works :)" println
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue