File::DataClass::Exception - Exception class composed from traits
use File::DataClass::Functions qw( throw ); use Try::Tiny; sub some_method { my $self = shift; try { this_will_fail } catch { throw $_ }; } # OR use File::DataClass::Exception; sub some_method { my $self = shift; eval { this_will_fail }; File::DataClass::Exception->throw_on_error; } # THEN try { $self->some_method() } catch { warn $_."\n\n".$_->stacktrace."\n" };
An exception class that supports error messages with placeholders, a "throw" in File::DataClass::Exception::TraitFor::Throwing method with automatic re-throw upon detection of self, conditional throw if an exception was caught and a simplified stacktrace
Applies exception roles to the exception base class Unexpected. See "Dependencies" for the list of roles that are applied
Error objects are overloaded to stringify to the full error message plus a leader if the optional ErrorLeader role has been applied
ErrorLeader
Ignores File::DataClass::IO when creating exception leaders
Defines these attributes;
out
A string containing the output from whatever was being called before it threw
Doesn't modify the BUILDARGS method. This is here to workaround a bug in Moo and / or Test::Pod::Coverage
BUILDARGS
$printable_string = $e->as_string
What an instance of this class stringifies to
$e = File::DataClass::Exception->caught( $error );
Catches and returns a thrown exception or generates a new exception if EVAL_ERROR has been set or if an error string was passed in
EVAL_ERROR
$clone = $e->clone;
Returns a clone of the exception object
$lines = $e->stacktrace( $num_lines_to_skip );
Return the stack trace. Defaults to skipping zero lines of output Skips anonymous stack frames, minimalist
File::DataClass::Exception->throw( $error );
Create (or re-throw) an exception to be caught by the "caught" method. If the passed parameter is a reference it is re-thrown. If a single scalar is passed it is taken to be an error message code, a new exception is created with all other parameters taking their default values. If more than one parameter is passed the it is treated as a list and used to instantiate the new exception. The error attribute must be provided in this case
error
File::DataClass::Exception->throw_on_error( $error );
Calls "caught" and if the was an exception "throw"s it
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Larry Wall - For the Perl programming language
Throwable::Error - Lifted the stack frame filter from here
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2017 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install File::DataClass, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::DataClass
CPAN shell
perl -MCPAN -e shell install File::DataClass
For more information on module installation, please visit the detailed CPAN module installation guide.