Skip to content

Instantly share code, notes, and snippets.

@tene
Created December 1, 2010 18:57
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 tene/724008 to your computer and use it in GitHub Desktop.
Save tene/724008 to your computer and use it in GitHub Desktop.
[sweeks@sweeks-laptop parrot]$ ./parrot /tmp/subthrow.pir
throwing parrot;Exception
in EH, caught a: Exception
message is: :(
Resuming...
back from EH
throwing LolException
in EH, caught a: LolException
message is: OHAI
Resuming...
back from EH
[sweeks@sweeks-laptop ~]$ parrot /tmp/subthrow.pir
throwing parrot;Exception
in EH, caught a: Exception
message is: :(
Resuming...
back from EH
throwing LolException
in EH, caught a: Exception
message is: Not a throwable object
Resuming...
back from EH
.sub main :main
.local pmc exc, lexc, lex
exc = get_class 'Exception'
lexc = subclass exc, 'LolException'
lex = new lexc
lex['message'] = 'OHAI'
push_eh gotit
say 'throwing parrot;Exception'
die ':('
say 'back from EH'
say 'throwing LolException'
throw lex
say 'back from EH'
pop_eh
exit 0
gotit:
.local pmc ex, cont
.local string msg, type
.get_results(ex)
type = typeof ex
print 'in EH, caught a: '
say type
msg = ex
print 'message is: '
say msg
say 'Resuming...'
cont = ex['resume']
cont()
.end
.namespace ['LolException']
.sub 'lol' :method
say 'ohai'
.end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment