X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=lib%2FApp%2FLazyShoppingList%2FAPI.pm;h=84e7fad4ace3775c82073ee7fdac6a6ae8e53370;hb=941f3fd80a4e9c96821a5e50f05bb04cf356304c;hp=c828974fa5782d4c2e94e12bf3835f2ddf9f0967;hpb=020687a66b8b6e53c68e50d14719f1cdf02e2975;p=lsl.git diff --git a/lib/App/LazyShoppingList/API.pm b/lib/App/LazyShoppingList/API.pm index c828974..84e7fad 100644 --- a/lib/App/LazyShoppingList/API.pm +++ b/lib/App/LazyShoppingList/API.pm @@ -9,7 +9,7 @@ use Exporter qw(import); our $VERSION = '0.1'; our @EXPORT = qw( &get_database &get_lists_version &increment_lists_version - &invalid_input ); + &invalid_input exception ); use Dancer2::Plugin::DBIC; @@ -66,8 +66,13 @@ sub increment_lists_version($dbh) { } sub invalid_input($details = undef) { - status 400; - return "Invalid input" . ( defined($details) ? " ($details)" : '' ); + return exception 400, + "Invalid input" . ( defined($details) ? " ($details)" : '' ); +} + +sub exception($http_code, $text) { + status $http_code; + return { exception => $text }; }