2 use strict; use warnings;
3 use Template qw(:template);
4 use OpenSRF::Utils::SettingsClient;
5 use OpenILS::Utils::Fieldmapper;
7 # ----------------------------------------------------------------------------------
8 # These exceptions are not thrown. They are returned as request result objects
9 # ----------------------------------------------------------------------------------
13 SEARCH_TOO_LARGE => 2,
15 DUPLICATE_INVALID_USER_BARCODE => 4,
16 DUPLICATE_USER_USERNAME => 5,
17 USER_WRONG_PASSWORD => 6,
18 PERMISSION_DENIED => 7,
20 MAX_RENEWALS_REACHED => 9,
21 COPY_NEEDED_FOR_HOLD => 10,
25 use overload ( '""' => sub { $_[0]->ex()->err_msg(); } );
29 my($class, $type) = @_;
30 $class = ref($class) || $class;
35 $self->{ex} = new Fieldmapper::ex;
36 $self->{ex}->type($ex_types{$type});
37 $self->{ex}->err_msg($self->run());
38 warn "type is $type\n";
44 sub ex { return shift()->{ex}; }
51 my $conf = OpenSRF::Utils::SettingsClient->new;
53 my $script = $conf->config_value("ex_script");
55 my $template = Template->new(
64 my $status = $template->process($script,
65 { ex_types => \%ex_types, type => $self->{ex}->type });
68 return "Unable to process exception script. No meaningful data to return..." .
69 " Error is:\n" . $template->error() . "\n";
72 $result =~ s/^\s*//og;
73 warn " -|-|-|- Exception result [$result]\n";