diff --git a/lib/RevBank/Global.pm b/lib/RevBank/Global.pm index 7e0091b..c5240e6 100644 --- a/lib/RevBank/Global.pm +++ b/lib/RevBank/Global.pm @@ -8,6 +8,12 @@ use POSIX qw(strftime); use RevBank::Amount; use RevBank::FileIO; +{ + package RevBank::Exception::RejectInput; + sub new($class, $reason) { return bless \$reason, $class; } + sub reason($self) { return $$self; } +} + sub import { require RevBank::Plugins; require RevBank::Users; @@ -48,10 +54,14 @@ sub import { $posneg and return undef; # last token must be term if ($amount->cents < 0) { - die "For our sanity, no negative amounts, please :).\n"; + die RevBank::Exception::RejectInput->new( + "For our sanity, no negative amounts, please :)." + ); } if ($amount->cents > 99900) { - die "That's way too much money.\n"; + die RevBank::Exception::RejectInput->new( + "That's way too much money." + ); } return $amount; }; diff --git a/revbank b/revbank index 5d20f0c..aad6e29 100755 --- a/revbank +++ b/revbank @@ -17,7 +17,7 @@ use RevBank::Messages; use RevBank::Cart; use RevBank::Prompt; -our $VERSION = "6.1.5"; +our $VERSION = "6.2.0"; our %HELP1 = ( "abort" => "Abort the current transaction", ); @@ -188,6 +188,9 @@ OUTER: for (;;) { @words = (); $retry = $@->reason; redo OUTER; + } elsif ($@ isa 'RevBank::Exception::RejectInput') { + $rv = REJECT; + @rvargs = $@->reason; } elsif ($@) { call_hooks "plugin_fail", $plugin->id, "$mname$@"; abort;