Merge pull request #213 from sminnee/http-error-catching

FIX Use RequestHandler::httpError() for all HTTP errors.
This commit is contained in:
Simon Welsh 2012-09-26 18:00:32 -07:00
commit 03ae8e3728
2 changed files with 6 additions and 10 deletions

View File

@ -205,11 +205,10 @@ class ContentController extends Controller {
* @uses ErrorPage::response_for() * @uses ErrorPage::response_for()
*/ */
public function httpError($code, $message = null) { public function httpError($code, $message = null) {
if($this->request->isMedia() || !$response = ErrorPage::response_for($code)) { // Don't use the HTML response for media requests
parent::httpError($code, $message); $response = $this->request->isMedia() ? null : ErrorPage::response_for($code);
} else { // Failover to $message if the HTML response is unavailable / inappropriate
throw new SS_HTTPResponse_Exception($response); parent::httpError($code, $response ? $response : $message);
}
} }
/** /**

View File

@ -126,11 +126,8 @@ class ModelAsController extends Controller implements NestedController {
return $this->response; return $this->response;
} }
if($response = ErrorPage::response_for(404)) { $response = ErrorPage::response_for(404);
return $response; $this->httpError(404, $response ? $response : 'The requested page could not be found.');
} else {
$this->httpError(404, 'The requested page could not be found.');
}
} }
// Enforce current locale setting to the loaded SiteTree object // Enforce current locale setting to the loaded SiteTree object