Name

File::DataClass::Exception - Base class for exception handling

Version

This documents version v0.18.$Rev: 4 $ of File::DataClass::Exception

Synopsis

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::Simple;

sub some_method {
   my $self = shift;

   eval { this_will_fail };
   File::DataClass::Exception::Simple->throw_on_error;
}

# THEN
try   { $self->some_method() }
catch { warn $_."\n\n".$_->stacktrace."\n" };

Description

An exception class that supports error messages with placeholders, a "throw" in File::DataClass::TraitFor::ThrowingExceptions method with automatic re-throw upon detection of self, conditional throw if an exception was caught and a simplified stacktrace

Error objects are overloaded to stringify to the full error message plus a leader

Configuration and Environment

The File::DataClass::Exception->Ignore class attribute is an array ref of methods whose presence should be ignored by the error message leader. It does the 'Array' trait where push implements the ignore_class method

Defines the following list of read only attributes;

args

An array ref of parameters substituted in for the placeholders in the error message when the error is localised

class

Defaults to __PACKAGE__. Can be used to differentiate different classes of error

error

The actually error message which defaults to Unknown error. Can contain placeholders of the form [_<n>] where <n> is an integer starting at one

Subroutines/Methods

as_string

$error_text = $self->as_string;

This is what the object stringifies to

is_one_of_us

$bool = $self->is_one_of_us( $string_or_exception_object_ref );

Class method which detects instances of this exception class

__build_attr_from

$hash_ref = __build_attr_from( @args );

Function that coerces a hash ref from whatever is passed to it

Diagnostics

None

Dependencies

namespace::clean
overload
Moose
MooseX::ClassAttribute
MooseX::Types::Common::String
MooseX::Types::Moose

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan <pjfl@cpan.org>

License and Copyright

Copyright (c) 2013 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