Skip Menu |
Report information
Id: 126717
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Carl Mäsak <cmasak [...] gmail.com>
To: rakudobug [...] perl.org
Date: Mon, 23 Nov 2015 21:12:57 +0100
Subject: [BUG] Exception generated within the .message method of a thrown exception is silently swallowed
Download (untitled) / with headers
text/plain 777b
<masak> m: class X::Test is Exception { method message { $.x } }; die X::Test.new <camelia> rakudo-moar : OUTPUT«X::Test exception produced no message [...] <masak> ^^ is a bit suboptimal <masak> if the message method fails for whatever reason, the exception "produced no message" It's technically correct that X::Test produced no message. But it would be even better if the exception that occurs inside of .message were thrown in some fashion: <masak> m: class X::Test is Exception { method message { $.x } }; X::Test.new.message <camelia> rakudo-moar : OUTPUT«Method 'x' not found for invocant of class 'X::Test' [...] If we can use our nested exceptions mechanism here somehow, so much the better. As long as we throw the exception from .message in one way or another.
Hi, On Mon Nov 23 12:13:07 2015, masak wrote: Show quoted text
> <masak> m: class X::Test is Exception { method message { $.x } }; die > X::Test.new > <camelia> rakudo-moar : OUTPUT«X::Test exception produced no message [...] > <masak> ^^ is a bit suboptimal > <masak> if the message method fails for whatever reason, the exception > "produced no message" > > It's technically correct that X::Test produced no message. But it > would be even better if the exception that occurs inside of .message > were thrown in some fashion:
The tricky thing here is avoiding recursion when the exception thrown from .message again produces an exception that throws an exception in its method message. Also, I'm not sure it's actually better to throw the exception, because people expect to be able to write try something() warn $! if $!; # go on here and code like this. I'd argue that throwing an exception from inside Exception.message is a violation of our (so far partially implicit) exception API, and the compiler's response to this is actually undefined behavior. I'd be happy to document it as such. Cheers, Moritz


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org