NAME

Object::Exception - Multi-threaded base exception class

VERSION

version 1.08

ABSTRACT

Multi-threaded base 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: $@";
	}
}

REPOSITORY

GitHub https://github.com/orkunkaraduman/p5-Object-Base

CPAN https://metacpan.org/release/Object-Base

AUTHOR

Orkun Karaduman <orkunkaraduman@gmail.com>

COPYRIGHT AND LICENSE

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/>.