Object::Exception - Multi-threaded exception class
version 1.14
Multi-threaded exception class
package SampleException; use Object::Base qw(Object::Exception); # package main; use Object::Exception; # # Enable DEBUG for traceback our $DEBUG = 1; # # throws Object::Exception type and its msg: Exception1 eval { throw("Exception1"); }; if ($@) { warn $@ if ref($@) eq "Object::Exception"; } # # throws SampleException type and its msg: This is sample exception sub sub_exception { SampleException->throw("This is sample exception"); } eval { sub_exception(); }; if ($@) { # $@ and $@->message returns same result warn $@->message if ref($@) eq "SampleException"; } # # throws Object::Exception type and its message: SampleException. Because msg is not defined! eval { SampleException->throw(); }; if ($@) { if (ref($@) eq "SampleException") { warn $@; } else { # warns 'This is type of Object::Exception and its message: SampleException' warn "This is type of ".ref($@)." and its message: $@"; } }
returns array specified level of traceback by calling point of traceback function.
returns string dump of trace array. Always ends with "\n".
dies with new Object::Exception instance with specified message.
returns new Object::Exception instance with specified message. If $main::DEBUG is setted TRUE, $object->debug attribute is setted 1.
returns message of Object::Exception instance. If $msg is defined with new() or throw(), always ends with "\n". If $object->debug attribute is TRUE, dump generated with dump_trace is added to end of message.
dies with new Object::Exception derived-class instance with specified message. If $class is not derived from Object::Exception, does nothing. $msg value must be specified explicitly and it can be undef. Otherwise, method runs as throw($class) function.
GitHub https://github.com/orkunkaraduman/p5-Object-Base
CPAN https://metacpan.org/release/Object-Base
Object::Base
Orkun Karaduman <orkunkaraduman@gmail.com>
Copyright (C) 2017 Orkun Karaduman <orkunkaraduman@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
To install Object::Base, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Base
CPAN shell
perl -MCPAN -e shell install Object::Base
For more information on module installation, please visit the detailed CPAN module installation guide.