Created
March 25, 2013 19:44
-
-
Save moritz/5240038 to your computer and use it in GitHub Desktop.
User-oriented stack traces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my role Described[$by] { | |
method description() { $by } | |
} | |
multi sub trait_mod:<is>(Routine:D $r, :$descr!) { | |
$r does Described[$descr]; | |
} | |
sub save-state() is descr('saving program state') { | |
save-all(); | |
} | |
sub save-all() { | |
save-config(); | |
} | |
sub save-config() is descr('saving user config') { | |
my $f = open :w, '/no/such/path'; | |
} | |
try save-state(); | |
if $! { | |
say "Error: $!.message()"; | |
for $!.backtrace.list { | |
if .code.^can('description') { | |
say " while ", $_.code.description() | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error: Unable to open filehandle from path '/no/such/path' | |
while saving user config | |
while saving program state |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment