#!/usr/bin/env perl
#
# test.pl - description
#
# Copyright (C) 2009 Stefan Pfetzing
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
use warnings;
use strict;
use Error::TryCatch;
use Error::Simple;
sub good {
print "good\n";
}
sub fail {
throw Error::Simple("Error::Simple failed.");
};
sub bad {
die "argh";
};
sub peng {
try {
print "peng(): try {} block\n";
good(); # do nothing bad
fail(); # throw Error::Simple
bad(); # is dying
print "peng(): try {} block done...\n";
} catch Error::Generic with {
print "error: ",$@;
};
};
try {
peng; # here an Error::Simple should be thrown
print "never reached.\n";
} catch Error::Simple with {
print STDERR "peng(): simple error\n";
} otherwise {
print STDERR "some die: $@\n";
};
# vim:set ft=perl fdm=marker fmr=><!>,<!><: