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.