Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: Non-fatal error handling with Mouse types?

by Corion (Pope)
on Oct 02, 2019 at 11:27 UTC ( #11106948=note: print w/replies, xml ) Need Help??

in reply to Re: Non-fatal error handling with Mouse types?
in thread Non-fatal error handling with Mouse types?

I think the issue is more with Moo*'s infatuation with Java-like error backtraces, which are rarely helpful. In most cases you want the bottom-level call within the code you're working with, not the full call stack in the maze of anonymous subroutine helpers that the Moo* family is so fond of.

Now that I talk about it, maybe a judicious application of Carp's %Carp::Internal could help clean up those tracebacks to a more manageable state?

#!perl use strict; package foo; use Mouse; use Mouse::Util::TypeConstraints; # Converted to Mouse: enum 'ErrorMode' => qw<carp error both>; has 'error_mode' => ( is => 'rw', isa => 'ErrorMode', default => 'erro +r' ); package main; use strict; use Carp; $Carp::Internal{ 'Mouse::Util' } = 1; $Carp::Verbose = 0; my $foo = foo->new( error_mode => 'silent' );

This eliminates at least Mouse::Util from the list of the backtrace. Most likely, more of these need to be added...

Replies are listed 'Best First'.
Re^3: Non-fatal error handling with Mouse types?
by wanna_code_perl (Friar) on Oct 02, 2019 at 13:14 UTC

    Thanks. Indeed, glad I wasn't the only one wondering what the point of those backtraces was. $Carp::Internal would certainly help clean that up a bit, and that's helpful. It's looking like I'd probably also have to do something along the lines of daxim's approach to override Mouse::Util::TypeConstraints->throw_error to make the errors non-fatal.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11106948]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2021-01-26 17:58 GMT
Find Nodes?
    Voting Booth?