Merge pull request #296 from chillu/pulls/validationexception-routing

API Handle uncaught ValidationException on CMS controller execution
This commit is contained in:
Andrew Short 2013-03-08 04:07:21 -08:00
commit 414f60ad2f
1 changed files with 9 additions and 0 deletions

View File

@ -314,6 +314,15 @@ class LeftAndMain extends Controller {
SSViewer::set_theme(null);
}
public function handleRequest(SS_HTTPRequest $request) {
try {
return parent::handleRequest($request);
} catch(ValidationException $e) {
// Nicer presentation of model-level validation errors
return $this->httpError(403, $e->getResult()->message());
}
}
/**
* If this is set to true, the "switchView" context in the