Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Exception-Class CPAN distribution.

Report information
The Basics
Id: 83311
Status: resolved
Priority: 0/
Queue: Exception-Class

People
Owner: Nobody in particular
Requestors: kstobie [...] tivo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.37



Subject: Explain use of Exception class with Try::Tiny
Date: Wed, 13 Feb 2013 23:07:37 +0000
To: "bug-exception-class [...] rt.cpan.org" <bug-exception-class [...] rt.cpan.org>
From: Keith Stobie <kstobie [...] tivo.com>
It would be nice if Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class-1.36/lib/Exception/Class.pm#___top> If you are interested in adding try/catch/finally syntactic sugar to your code then I recommend you check out Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a great module that helps you ignore some of the weirdness with eval and $@. was ammended with what I found at http://www.perlmonks.org/?node_id=998104 Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class-1.36/lib/Exception/Class.pm#___top> If you are interested in adding try/catch/finally syntactic sugar to your code then I recommend you check out Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a great module that helps you ignore some of the weirdness with eval and $@. Because Exception::Class->caught() explicitly checks $@ for the exception object with Try::Tiny you simplify this to something like: catch { $e = $_; if(UNIVERSAL::isa($e,'MyException')) { warn $e->error, "\n"; ... } } Show quoted text
________________________________ This email and any attachments may contain confidential and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments) by others is prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete this email and any attachments. No employee or agent of TiVo Inc. is authorized to conclude any binding agreement on behalf of TiVo Inc. by email. Binding agreements with TiVo Inc. may only be made by a signed written agreement.
On Wed Feb 13 18:07:49 2013, kstobie@tivo.com wrote: Show quoted text
> It would be nice if > > > Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class- > 1.36/lib/Exception/Class.pm#___top> > > If you are interested in adding try/catch/finally syntactic sugar to > your code then I recommend you check out > Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a > great module that helps you ignore some of the weirdness with eval > and $@. > > > was ammended with what I found at > http://www.perlmonks.org/?node_id=998104 > > > Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class- > 1.36/lib/Exception/Class.pm#___top> > > If you are interested in adding try/catch/finally syntactic sugar to > your code then I recommend you check out > Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a > great module that helps you ignore some of the weirdness with eval > and $@. > > Because Exception::Class->caught() explicitly checks $@ for the > exception object with Try::Tiny you simplify this to something > like: > > catch { > $e = $_; > if(UNIVERSAL::isa($e,'MyException')) { > warn $e->error, "\n"; > ... > } > }
Calling UNIVERSAL::isa that way is never a good idea. Objects can override the isa() method and code should respect that.
Subject: Re: [rt.cpan.org #83311] Explain use of Exception class with Try::Tiny
Date: Fri, 22 Feb 2013 18:59:14 +0000
To: "bug-Exception-Class [...] rt.cpan.org" <bug-Exception-Class [...] rt.cpan.org>
From: Keith Stobie <kstobie [...] tivo.com>
Thanks for the info. Is there ANY recommended way to use Try::Tiny with the Exception class? The one I sent was the only way I saw recommend, many people just said you can't use them together. On 2/22/13 8:11 AM, "Dave Rolsky via RT" <bug-Exception-Class@rt.cpan.org> wrote: Show quoted text
><URL: https://rt.cpan.org/Ticket/Display.html?id=83311 > > >On Wed Feb 13 18:07:49 2013, kstobie@tivo.com wrote:
>> It would be nice if >> >> >> Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class- >> 1.36/lib/Exception/Class.pm#___top> >> >> If you are interested in adding try/catch/finally syntactic sugar to >> your code then I recommend you check out >> Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a >> great module that helps you ignore some of the weirdness with eval >> and $@. >> >> >> was ammended with what I found at >> http://www.perlmonks.org/?node_id=998104 >> >> >> Try::Tiny [^] <http://search.cpan.org/%7Edrolsky/Exception-Class- >> 1.36/lib/Exception/Class.pm#___top> >> >> If you are interested in adding try/catch/finally syntactic sugar to >> your code then I recommend you check out >> Try::Tiny<http://search.cpan.org/perldoc?Try%3A%3ATiny>. This is a >> great module that helps you ignore some of the weirdness with eval >> and $@. >> >> Because Exception::Class->caught() explicitly checks $@ for the >> exception object with Try::Tiny you simplify this to something >> like: >> >> catch { >> $e = $_; >> if(UNIVERSAL::isa($e,'MyException')) { >> warn $e->error, "\n"; >> ... >> } >> }
> >Calling UNIVERSAL::isa that way is never a good idea. Objects can >override the isa() method and code should respect that.
Show quoted text
________________________________ This email and any attachments may contain confidential and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments) by others is prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete this email and any attachments. No employee or agent of TiVo Inc. is authorized to conclude any binding agreement on behalf of TiVo Inc. by email. Binding agreements with TiVo Inc. may only be made by a signed written agreement.
Subject: Re: [rt.cpan.org #83311] Explain use of Exception class with Try::Tiny
Date: Fri, 22 Feb 2013 13:04:05 -0600 (CST)
To: Keith Stobie via RT <bug-Exception-Class [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Fri, 22 Feb 2013, Keith Stobie via RT wrote: Show quoted text
> Is there ANY recommended way to use Try::Tiny with the Exception class?
I didn't think there was much to worry about. I use them together all the time. try { ... } catch { if ( blessed $_ && $_->isa('Some::Exception::Class') ) { ... } }; Show quoted text
> The one I sent was the only way I saw recommend, many people just said you > can't use them together.
Many people are wrong. It's just that the ->caught method isn't needed with Try::Tiny. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Subject: Re: [rt.cpan.org #83311] Explain use of Exception class with Try::Tiny
Date: Fri, 22 Feb 2013 20:17:04 +0000
To: "bug-Exception-Class [...] rt.cpan.org" <bug-Exception-Class [...] rt.cpan.org>
From: Keith Stobie <kstobie [...] tivo.com>
Thanks! My request is merely that your example be added to the Exception class POD. On 2/22/13 11:04 AM, "autarch@urth.org via RT" <bug-Exception-Class@rt.cpan.org> wrote: Show quoted text
><URL: https://rt.cpan.org/Ticket/Display.html?id=83311 > > >On Fri, 22 Feb 2013, Keith Stobie via RT wrote: >
>> Is there ANY recommended way to use Try::Tiny with the Exception class?
> >I didn't think there was much to worry about. I use them together all the >time. > > try { ... } > catch { > if ( blessed $_ && $_->isa('Some::Exception::Class') ) { ... } > }; >
>> The one I sent was the only way I saw recommend, many people just said >>you >> can't use them together.
> >Many people are wrong. It's just that the ->caught method isn't needed >with Try::Tiny. > > >-dave > >/*============================================================ >http://VegGuide.org http://blog.urth.org >Your guide to all that's veg House Absolute(ly Pointless) >============================================================*/ >
Show quoted text
________________________________ This email and any attachments may contain confidential and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments) by others is prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete this email and any attachments. No employee or agent of TiVo Inc. is authorized to conclude any binding agreement on behalf of TiVo Inc. by email. Binding agreements with TiVo Inc. may only be made by a signed written agreement.
Subject: Re: [rt.cpan.org #83311] Explain use of Exception class with Try::Tiny
Date: Fri, 22 Feb 2013 17:15:35 -0600 (CST)
To: Keith Stobie via RT <bug-Exception-Class [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Fri, 22 Feb 2013, Keith Stobie via RT wrote: Show quoted text
> Thanks! > My request is merely that your example be added to the Exception class POD.
Ah, of course. I will do that for the next release. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/