|
I put the following sub in my code.
sub check_object_type {
my ($object, $expected_type) = @_;
unless(Object::InsideOut::is_it($object, $expected_type)) {
my actual_type = ref($object);
OIO::Args->
die('message' => q/Bad parameter: Wrong type/,
'Usage' => "Expected an object or ref of type \"$expected_type\", ".
"but saw an object or ref of type \"actual_type\"");
}
}
I want die to report the line of the caller's caller, not the caller.The body of this sub use to occur several times in my code. So, I decided to make this sub and the replace the redundant segments with a sub call. However, I don't want the reported line to change.
If I was using Carp, I suspect I would have to do a "local Carp::CarpLevel = 1;" before the Carp call.
I was having difficult solving this problem, because
I couldn't find the die method declaration in Exception::Class or Object::InsideOut. |