]> git.ktnx.net Git - lsl.git/blobdiff - lib/App/LazyShoppingList/API.pm
move sub declaration before usage
[lsl.git] / lib / App / LazyShoppingList / API.pm
index c828974fa5782d4c2e94e12bf3835f2ddf9f0967..36f7e6863aa1f533c0371d956e1aa1b4630b2743 100644 (file)
@@ -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;
 
@@ -65,9 +65,14 @@ sub increment_lists_version($dbh) {
     return $g->lists_version;
 }
 
+sub exception($http_code, $text) {
+    status $http_code;
+    return { exception => $text };
+}
+
 sub invalid_input($details = undef) {
-    status 400;
-    return "Invalid input" . ( defined($details) ? " ($details)" : '' );
+    return exception 400,
+        "Invalid input" . ( defined($details) ? " ($details)" : '' );
 }