Tpl: add display_ajax_error() helper method
This commit is contained in:
parent
85544a36b8
commit
7e57aa2ed8
1 changed files with 21 additions and 1 deletions
22
src/Tpl.php
22
src/Tpl.php
|
@ -550,6 +550,26 @@ class Tpl {
|
|||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display AJAX error
|
||||
* @param string|null $error Error message (optional)
|
||||
* @param bool $pretty AJAX returned data
|
||||
* (optional, default: true if $_REQUEST['pretty'] is set, False otherwise)
|
||||
* @return never
|
||||
*/
|
||||
public static function display_ajax_error($error=null, $pretty=false) {
|
||||
self :: display_ajax_return(
|
||||
array(
|
||||
'success' => false,
|
||||
'error' => (
|
||||
$error?
|
||||
$error:
|
||||
I18n::_("Unexpected error occured. If problem persist, please contact support.")
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a fatal error
|
||||
* @param string $error The error message
|
||||
|
@ -576,7 +596,7 @@ class Tpl {
|
|||
|
||||
// Handle API mode
|
||||
if (Url :: api_mode())
|
||||
self :: display_ajax_return(array('success' => false, 'error' => $error));
|
||||
self :: display_ajax_error($error);
|
||||
|
||||
self :: assign('fatal_error', $error);
|
||||
self :: display('fatal_error.tpl');
|
||||
|
|
Loading…
Reference in a new issue