in reply to Error.pm and custom Exception

Briefly, new(...) is a class method whose first parameter is the name of the class. So, what you are calling $self is actually a string rather than an error object. And when you return $self, you are returning the class name string from your constructor rather than the error object.

Your class definition should look more like this: (untested code)

use strict; use warnings; package DB::DBException; use base qw(Error); sub new { my ($sClass, $msg) = @_; my @args = (); local $Error::Depth = $Error::Depth + 1; local $Error::Debug = 1; # Enables storing of stacktrace # *** this is the key line change *** my $self = $sClass->SUPER::new(-text => $msg, @args); return $self; }