Fukurama::Class::Carp - Carp-Adapter to easy extend the carp-level


Fukurama-Class documentation Contained in the Fukurama-Class distribution.

Index


Code Index:

NAME

Top

Fukurama::Class::Carp - Carp-Adapter to easy extend the carp-level

VERSION

Top

Version 0.01 (beta)

SYNOPSIS

Top

 use Fukurama::Class::Carp;

 sub foo {
 	bar();
 }
 sub bar {
 	baz();
 }
 sub baz {
 	# would croak in foo()
 	croak('its not my fault', 1);
 }

DESCRIPTION

Top

This module provides a simple method to change the $Carp::CarpLevel locally. This is a helperclass for Fukurama::Class.

CONFIG

Top

-

EXPORT

Top

_carp( message:STRING, [ addCarpLevel:INT ] ) return:VOID

It's like Carp::carp(). It will warn about an error in the callers context. But you can increase the carp-level with a parameter

_croak( message:STRING, [ addCarpLevel:INT ] ) return:VOID

It's like Carp::croak(). It will die an error in the callers context. But you can increase the carp-level with a parameter

METHODS

Top

-

AUTHOR, BUGS, SUPPORT, ACKNOWLEDGEMENTS, COPYRIGHT & LICENSE

Top

see perldoc of Fukurama::Class


Fukurama-Class documentation Contained in the Fukurama-Class distribution.

package Fukurama::Class::Carp;
our $VERSION = 0.01;
use strict;
use warnings;

use Carp();

# AUTOMAGIC void
sub import {
	my $class = $_[0];
	
	no strict 'refs';
	
	my ($caller) = caller(0);
	*{$caller . '::_carp'} = \&_carp;
	*{$caller . '::_croak'} = \&_croak;
	return;
}
# DIRECT void
sub _carp {
	my $msg = $_[0];
	my $level = $_[1];
	
	$level ||= 0;
	
	no strict 'refs';
	
	my ($caller) = caller(0);
	local $Carp::CarpLevel = $Carp::CarpLevel + $level + 1;
	Carp::carp($msg);
	return;
}
# DIRECT void
sub _croak {
	my $msg = $_[0];
	my $level = $_[1];
	
	$level ||= 0;
	
	local $Carp::CarpLevel = $Carp::CarpLevel + $level + 1;
	Carp::croak($msg);
	return;
}
1;