mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Move friendly error message feature to Message module
This commit is contained in:
parent
26710e2675
commit
e31704ffc2
9 changed files with 41 additions and 20 deletions
|
|
@ -7,17 +7,10 @@
|
|||
*/
|
||||
class MessageView extends Message
|
||||
{
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Display messages
|
||||
*/
|
||||
function dispMessage($detail = null, $location = null)
|
||||
public function dispMessage($detail = null, $location = null)
|
||||
{
|
||||
// Get skin configuration
|
||||
$config = ModuleModel::getModuleConfig('message') ?: new stdClass;
|
||||
|
|
@ -79,6 +72,7 @@ class MessageView extends Message
|
|||
Context::set('ssl_mode', \RX_SSL);
|
||||
Context::set('system_message', nl2br($this->getMessage()));
|
||||
Context::set('system_message_detail', nl2br($detail));
|
||||
Context::set('system_message_help', self::getErrorHelp($detail));
|
||||
Context::set('system_message_location', escape($location));
|
||||
|
||||
if ($this->getError())
|
||||
|
|
@ -101,6 +95,29 @@ class MessageView extends Message
|
|||
$this->setHttpStatusCode(403);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get friendly help message for common types of errors.
|
||||
*
|
||||
* @param string $error_message
|
||||
* @return string
|
||||
*/
|
||||
public static function getErrorHelp(string $error_message): string
|
||||
{
|
||||
$regexp_list = [
|
||||
'/Class [\'"]Object[\'"] not found/' => 'baseobject',
|
||||
];
|
||||
|
||||
foreach ($regexp_list as $regexp => $key)
|
||||
{
|
||||
if (preg_match($regexp, $error_message))
|
||||
{
|
||||
return lang('message.error_help.' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/* End of file message.view.php */
|
||||
/* Location: ./modules/message/message.view.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue