NAME

OpenGbg::Exception - When something fails

SYNOPSIS

use Safe::Isa;
use Try::Tiny:
my $handler = OpenGbg->new(key => 'secret-api-key');

my $response;
try {
    $response = $handler->styr_och_stall->get_bike_stations;
}
catch {
    my $error = $_;
    if($error->$_does('OpenGbg::Exception')) {
        $error->out;
    }
    else {
        die $_;
    }
};

DESCRIPTION

OpenGbg::Exception is the role all exceptions do.

ATTRIBUTES

info

An error message containing all information the thrown exception has about the error.

METHODS

out

Prints info and a stack trace.

fatal

Dies.

catch {
    my $error = $_;
    if($error->$_does('OpenGbg::Exception')) {
        $error->out->fatal;
    }
    else {
        die $_;
    }
};

AUTHOR

Erik Carlsson <info@code301.com>

COPYRIGHT

Copyright 2014 - Erik Carlsson

LICENSE

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