mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-07-11 17:53:50 -04:00
Catch ORM_Validation_Exception and turn it into a 400 Bad Request with
appropriate error output.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user