summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/rest/controllers/rest.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php
index 5ef9eb84..cac49740 100644
--- a/modules/rest/controllers/rest.php
+++ b/modules/rest/controllers/rest.php
@@ -72,7 +72,14 @@ class Rest_Controller extends Controller {
throw new Rest_Exception("Forbidden", 403);
}
- print call_user_func(array($handler_class, $handler_method), $request);
+ try {
+ print call_user_func(array($handler_class, $handler_method), $request);
+ } catch (ORM_Validation_Exception $e) {
+ foreach ($e->validation->errors() as $key => $value) {
+ $msgs[] = "$key: $value";
+ }
+ throw new Rest_Exception("Bad Request: " . join(", ", $msgs), 400);
+ }
} catch (Rest_Exception $e) {
rest::send_headers($e);
}