Skip to content

Instantly share code, notes, and snippets.

@repomaa
Created August 31, 2018 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save repomaa/a9f16d5f7a902e5ffca6f49b7d0027a4 to your computer and use it in GitHub Desktop.
Save repomaa/a9f16d5f7a902e5ffca6f49b7d0027a4 to your computer and use it in GitHub Desktop.
class AError < Exception
getter foo
def initialize(@foo : String, message)
super(message)
end
end
class BError < Exception
getter foo
def initialize(@foo : String, message)
super(message)
end
end
class CError < Exception
getter foo
def initialize(@foo : String, message)
super(message)
end
end
alias MyError = AError | BError | CError
begin
puts "hi"
rescue ex : MyError
puts(ex.foo)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment