-
-
31 Jul 2017 21:47:25 UTC
- Distribution: Unexpected
- Module version: v1.0.1
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (1)
- Testers (807 / 0 / 0)
- Kwalitee
Bus factor: 0- 99.47% Coverage
- License: perl_5
- Perl: v5.10.1
- Activity
24 month- Tools
- Download (35.2KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Devel::StackTrace
- Exporter::Tiny
- Module::Runtime
- Moo
- Package::Stash
- Sub::Install
- Type::Tiny
- namespace::autoclean
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- Name
- Synopsis
- Description
- Configuration and Environment
- Subroutines/Methods
- Diagnostics
- Dependencies
- Incompatibilities
- Bugs and Limitations
- Acknowledgements
- Author
- License and Copyright
Name
Unexpected - Localised exception classes composed from roles
Synopsis
package YourApp::Exception; use Moo; extends 'Unexpected'; with 'Unexpected::TraitFor::ErrorLeader'; __PACKAGE__->ignore_class( 'YourApp::IgnoreMe' ); has '+class' => default => __PACKAGE__; package YourApp; use YourApp::Exception; use Try::Tiny; sub some_method { my $self = shift; try { this_will_fail } catch { YourApp::Exception->throw $_ }; } # OR sub some_method { my $self = shift; eval { this_will_fail }; YourApp::Exception->throw_on_error; } # THEN try { $self->some_method() } catch { warn $_->message };
Description
An exception class that supports error messages with placeholders, a throw method with automatic re-throw upon detection of self, conditional throw if an exception was caught and a simplified stack trace in addition to the error message with full stack trace
Configuration and Environment
Applies exception roles to the exception base class Unexpected. See "Dependencies" for the list of roles that are applied
The list of signatures recognised by the constructor method is implemented by the signature parser
Error objects are overloaded to stringify to the full error message plus a leader if the optional Unexpected::TraitFor::ErrorLeader role has been applied
Subroutines/Methods
BUILD
Empty subroutine which is modified by the applied roles
BUILDARGS
Differentiates different constructor method signatures
Diagnostics
String overload is performed in this class as opposed to the stringify error role since overloading is not supported in Moo::Role
Dependencies
- namespace::autoclean
- overload
- Moo
- Unexpected::TraitFor::ExceptionClasses
- Unexpected::TraitFor::StringifyingError
- Unexpected::TraitFor::Throwing
- Unexpected::TraitFor::TracingStacks
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
Throwable did not let me use the stack trace filter directly, it's wrapped inside an attribute constructor. There was nothing else in Throwable that would not have been overridden
There are no known bugs in this module. Please report problems to http://rt.cpan.org/NoAuth/Bugs.html?Dist=Unexpected. Patches are welcome
Acknowledgements
Larry Wall - For the Perl programming language
Throwable::Error - Lifted the stack frame filter from here
John Sargent - Came up with the package name
Author
Peter Flanigan,
<pjfl@cpan.org>
License and Copyright
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
Module Install Instructions
To install Unexpected, copy and paste the appropriate command in to your terminal.
cpanm Unexpected
perl -MCPAN -e shell install Unexpected
For more information on module installation, please visit the detailed CPAN module installation guide.