mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #213 from sminnee/http-error-catching
FIX Use RequestHandler::httpError() for all HTTP errors.
This commit is contained in:
commit
03ae8e3728
@ -205,11 +205,10 @@ class ContentController extends Controller {
|
||||
* @uses ErrorPage::response_for()
|
||||
*/
|
||||
public function httpError($code, $message = null) {
|
||||
if($this->request->isMedia() || !$response = ErrorPage::response_for($code)) {
|
||||
parent::httpError($code, $message);
|
||||
} else {
|
||||
throw new SS_HTTPResponse_Exception($response);
|
||||
}
|
||||
// Don't use the HTML response for media requests
|
||||
$response = $this->request->isMedia() ? null : ErrorPage::response_for($code);
|
||||
// Failover to $message if the HTML response is unavailable / inappropriate
|
||||
parent::httpError($code, $response ? $response : $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,11 +126,8 @@ class ModelAsController extends Controller implements NestedController {
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
if($response = ErrorPage::response_for(404)) {
|
||||
return $response;
|
||||
} else {
|
||||
$this->httpError(404, 'The requested page could not be found.');
|
||||
}
|
||||
$response = ErrorPage::response_for(404);
|
||||
$this->httpError(404, $response ? $response : 'The requested page could not be found.');
|
||||
}
|
||||
|
||||
// Enforce current locale setting to the loaded SiteTree object
|
||||
|
Loading…
Reference in New Issue
Block a user