NAME

Simo::Error - Error object for Simo

VERSION

Version 0.01_01

DESCRIPTION

Simo::Error provide structured error system to Simo.

You can create structure err message.

If err is ocuured, You can get err object;

SYNOPSIS

use Simo::Error;

# create structured error string
my $err_str = Simo::Error->create_err_str( 
    type => 'err_type',
    msg => 'message',
    a => 'some 1';
    b => 'some 2';
);

# $err_str is 
# "Error: { type => 'err_type', msg => 'message' }"

# this can use with croak or die;
eval{
    croak $err;
}

# get err object
my $err_obj = Simo::Error->create_from_err_str( $@ );

# check err
if( $err_obj ){
    if( $err_obj->type eq 'err_type' ){
        my $msg = $err_obj->msg;
        my $pos = $err_obj->pos; # error occured place, which 'croak' create.
        my $info = $err_obj->info; # other than type, msg, pos is packed into info.
        
        my $a = $info->{ a };
        my $b = $ingo->{ b };
    }
}

CLASS METHOD

create_err_str

create structured error string.

my $err_str = Simo::Error->create_err_str( 
    type => 'err_type',
    msg => 'message'
);

Structured error stirng is like

Error: { type => 'err_type', msg => 'message' }

You can convert this stuructured error string to error object by using create_from_err_str.

This method is used with croak or die.

croak Simo::Error->create_err_str( 
    type => 'err_type',
    msg => 'message'
);

ACCESSOR

type

is error type.

msg

is error message

pos

is position in which error is occured.

You do not have to specify this attr in create_err_str argument.

pos is automatically set, parsing croak message or die message.

info

is information other than type, msg or pos.

This is hash ref.

METHOD

new

is constructor;

my $err_obj = Simo::Error->new(
    type => 'err_type',
    msg => 'message',
    pos => 'position error occured',
    info => { some1 => 'some info1', some2 => 'some info2' }
);

create_from_err_str

is create Simo::Error object parsing error sting

Error string is usually created by create_err_str method.

AUTHOR

Yuki Kimoto, <kimoto.yuki at gmail.com>

BUGS

Please report any bugs or feature requests to bug-simo-error at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Simo-Error. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Simo::Error

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2009 Yuki Kimoto, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.