Luka::Exceptions - exception classes


Luka documentation Contained in the Luka distribution.

Index


Code Index:

NAME

Top

Luka::Exceptions - exception classes

SYNOPSIS

Top

    use Luka::Exceptions;
    use Error qw(:try);
    push @Exception::Class::Base::ISA, 'Error'
        unless Exception::Class::Base->isa('Error');

    try {
        # some external library that dies unexpectedly
	do_something();
    }
    catch Error with {
        # this will catch errors of any type
        $e = shift;
        throw Luka::Exception::Program( error => $e, show_trace => 1 );
    };

DESCRIPTION

Top

This class provides custom exceptions for Luka.

EXCEPTION types

Top

There are three exceptions that can be thrown:

Luka::Exception::External

network and OS errors (connectivity, file system);

Luka::Exception::User

user interaction related errors

Luka::Exception::Program

internal program errors

EXCEPTION attributes

Top

All classes have the same fields: error, context, args, path, severity, conf, show_trace.

error

Error string thrown by library, in perl $! or $@.

context

Explanation of exception that ought to out error in context for the person dealing with it who doesn't necessarily know much about the script. For example, if an FTP connection fails we should report:

    FTP error: geting SpecialData feed from Someone failed.

and not anything similar to:

    FTP connection failed.

Why? Because to someone dealing with the problem, but not familiar with the application, FTP connection failed says nothing new - usualy, that info is already present in the library error, which should always be in the error field of the exception thrown. So, instead of replicating information provided by the machine, give information known only to you, developer:

object/component dealt with
desired outcome and its importance of its functionality
remote side involved

args

Arguments that might be needed for resolving the reasons for failure: either those provided to the subroutine from which exception is thrown or those supplied to the external library whose error we're dealing with.

show_trace

If assigned value 1, this option will include stack trace.

severity

Severity level of the error thrown. See TODO section in Luka.

id

Id of the error thrown. Can be used as a namespace for tracking errors and linking to appropriate documentation.

conf

Configuration used for Luka system. Used for testing only.

SEE ALSO

Top

Exception::Class, Luka

AUTHOR

Top

Toni Prug <toni@irational.org>

COPYRIGHT

Top


Luka documentation Contained in the Luka distribution.
# $Id: Exceptions.pm,v 1.4 2006/02/27 21:43:59 toni Exp $
package Luka::Exceptions;

$VERSION = "1.02";

BEGIN { $Exception::Class::BASE_EXC_CLASS = 'Luka::ExceptionBase'; }

use Exception::Class (  Luka::Exception,
			    Luka::Exception::External =>
			    {  
			        isa => 'Luka::Exception',
			        description => 'external exception',
			        fields => [ 'id', 'context', 'args', 'path', 'severity', 'conf' ],
			     },
			     Luka::Exception::User =>
			     { 
			         isa => 'Luka::Exception',
			         description => 'user related exception',
			         fields => [ 'id', 'context', 'args', 'path', 'severity', 'conf' ],
			     },
			     Luka::Exception::Program =>
			     {
			         isa => 'Luka::Exception',
			         description => 'internal programming exception',
			         fields => [ 'id', 'context', 'args', 'path', 'severity' , 'conf'],
			     },
			);

1;