API CHANGE: Added Debug::$friendly_error_header and Debug::$friendly_error_detail for customising the friendly error message. (from r69855)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88632 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-10-12 03:20:24 +00:00
parent 1380c3f53c
commit c347278dda

View File

@ -47,6 +47,16 @@ class Debug {
* name, but with the suffix ".full" added.
*/
protected static $log_errors_to = null;
/**
* The header of the message shown to users on the live site when a fatal error occurs.
*/
public static $friendly_error_header = 'There has been an error';
/**
* The body of the message shown to users on the live site when a fatal error occurs.
*/
public static $friendly_error_detail = 'The website server has not been able to respond to your request.';
/**
* Show the contents of val in a debug-friendly way.
@ -304,8 +314,8 @@ class Debug {
* @return string HTML error message for non-ajax requests, plaintext for ajax-request.
*/
static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null) {
if(!$friendlyErrorMessage) $friendlyErrorMessage = 'There has been an error';
if(!$friendlyErrorDetail) $friendlyErrorDetail = 'The website server has not been able to respond to your request.';
if(!$friendlyErrorMessage) $friendlyErrorMessage = self::$friendly_error_header;
if(!$friendlyErrorDetail) $friendlyErrorDetail = self::$friendly_error_detail;
if(!headers_sent()) header($_SERVER['SERVER_PROTOCOL'] . " $statusCode $friendlyErrorMessage");