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,
19 use overload ( '""' => sub { $_[0]->ex()->err_msg(); } );
23 my($class, $type) = @_;
24 $class = ref($class) || $class;
29 $self->{ex} = new Fieldmapper::ex;
30 $self->{ex}->type($ex_types{$type});
31 $self->{ex}->err_msg($self->run());
32 warn "type is $type\n";
38 sub ex { return shift()->{ex}; }
45 my $conf = OpenSRF::Utils::SettingsClient->new;
47 my $script = $conf->config_value("ex_script");
49 my $template = Template->new(
58 my $status = $template->process($script,
59 { ex_types => \%ex_types, type => $self->{ex}->type });
62 return "Unable to process exception script. No meaningful data to return..." .
63 " Error is:\n" . $template->error() . "\n";
66 $result =~ s/^\s*//og;
67 warn " -|-|-|- Exception result [$result]\n";