1 use Test::More tests => 25;
7 # check exception serialization
11 SL::X::Inventory::Allocation
12 SL::X::ZUGFeRDValidation
15 # check basic mesage / error serialization
17 for my $error_class (@classes) {
19 my $x = $error_class->new(message => "test message");
21 is $x->error, "test message", "$error_class(message): error works";
22 is $x->message, "test message", "$error_class(message): message works";
23 is "$x", "test message", "$error_class(message): stringify works";
25 $x = $error_class->new(error => "test message");
27 is $x->error, "test message", "$error_class(error): error works";
28 is $x->message, "test message", "$error_class(error): message works";
29 is "$x", "test message", "$error_class(error): stringify works";
33 # now create some classes with message templates and extra fields
35 my $x = SL::X::DBError->new(msg => "stuff", db_error => "broke");
37 is $x->error, "stuff: broke", "template: error works";
38 is $x->message, "stuff: broke", "tempalte: message works";
39 is "$x", "stuff: broke", "template: stringify works";
42 $x = SL::X::Inventory::Allocation->new(code => "DEADCOFFEE", message => "something went wrong");
44 is $x->code, "DEADCOFFEE", "extra fields work";
55 sub f { SL::X::DBError->throw() }
60 if (my $e = SL::X::DBError->caught) {
61 ok 1, "caught db error";
62 ok $e->trace->as_string =~ /main::a/, "trace contains function a";
63 ok $e->trace->as_string =~ /main::f/, "trace contains function f";
66 ok 0, "didn't catch db error";