Data::Object::Exception
Exception Class for Perl 5
use Data::Object::Exception; my $exception = Data::Object::Exception->new; # $exception->throw
This package provides functionality for creating, throwing, and introspecting exception objects.
This package supports the following scenarios:
use Data::Object::Exception; my $exception = Data::Object::Exception->new('Oops!'); # $exception->throw
The package allows objects to be instantiated with a single argument.
use Data::Object::Exception; my $exception = Data::Object::Exception->new(message => 'Oops!'); # $exception->throw
The package allows objects to be instantiated with key-value arguments.
This package has the following attributes:
context(Any)
This attribute is read-only, accepts (Any) values, and is optional.
(Any)
id(Str)
This attribute is read-only, accepts (Str) values, and is optional.
(Str)
message(Str)
This package implements the following methods:
explain() : Str
The explain method returns an error message with stack trace.
use Data::Object::Exception; my $exception = Data::Object::Exception->new('Oops!'); $exception->explain
throw(Tuple[Str, Str] | Str $message, Any $context, Maybe[Number] $offset) : Any
The throw method throws an error with message (and optionally, an ID).
use Data::Object::Exception; my $exception = Data::Object::Exception->new; $exception->throw('Oops!')
use Data::Object::Exception; my $exception = Data::Object::Exception->new('Oops!'); $exception->throw
use Data::Object::Exception; my $exception = Data::Object::Exception->new; $exception->throw(['E001', 'Oops!'])
trace(Int $offset, $Int $limit) : Object
The trace method compiles a stack trace and returns the object. By default it skips the first frame.
use Data::Object::Exception; my $exception = Data::Object::Exception->new('Oops!'); $exception->trace(0)
use Data::Object::Exception; my $exception = Data::Object::Exception->new('Oops!'); $exception->trace(1)
use Data::Object::Exception; my $exception = Data::Object::Exception->new('Oops!'); $exception->trace(0,1)
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Data::Object::Exception, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Object::Exception
CPAN shell
perl -MCPAN -e shell install Data::Object::Exception
For more information on module installation, please visit the detailed CPAN module installation guide.