Show friendly error message for very common error conditions, such as Object class

This commit is contained in:
Kijin Sung 2023-08-07 15:14:47 +09:00
parent 3ea1567fda
commit df6ccfc7d4
3 changed files with 11 additions and 3 deletions

View file

@ -628,24 +628,30 @@ class Debug
}
// Add the exception to the error log.
if ($caller_errfile && $caller_errfile !== $errfile)
{
$log_entry = str_replace("\0", '', sprintf('%s #%d "%s" in %s on line %d (via %s on line %d)',
get_class($e), $e->getCode(), $e->getMessage(), $caller_errfile, $caller_errline, $errfile, $e->getLine()));
$friendly_entry = $log_entry;
}
else
{
$log_entry = str_replace("\0", '', sprintf('%s #%d "%s" in %s on line %d',
get_class($e), $e->getCode(), $e->getMessage(), $errfile, $e->getLine()));
$friendly_entry = $log_entry;
if ($e->getMessage() === 'Class "Object" not found')
{
$friendly_entry .= "\n\n" . lang('msg_baseobject_fix');
}
}
if (!isset(self::$_config['write_error_log']) || self::$_config['write_error_log'] !== 'none')
{
error_log('PHP Exception: ' . $log_entry . \PHP_EOL . self::formatBacktrace($e->getTrace()));
}
// Display the error screen.
self::displayErrorScreen($log_entry);
self::displayErrorScreen($friendly_entry);
exit;
}

View file

@ -342,6 +342,7 @@ $lang->filter['invalid_number'] = 'The format of %s is invalid. Please enter num
$lang->filter['invalid_float'] = 'The format of %s is invalid. Please enter numbers only.';
$lang->filter['invalid_extension'] = 'The format of %s is invalid. e.g. gif, jpg, png';
$lang->security_warning_embed = 'Due to security concern, administrators are not allowed to view embedded items.<BR /> To view them, please use another non-administrator ID.';
$lang->msg_baseobject_fix = 'Object → BaseObject conversion is required in a third-party program. Please fix it by consulting the file name and line number shown above.';
$lang->msg_pc_to_mobile = 'View mobile optimized version of this page';
$lang->cmd_yes = 'Yes';
$lang->cmd_no = 'No';

View file

@ -346,6 +346,7 @@ $lang->filter['invalid_float'] = '%s의 형식이 잘못되었습니다. 숫자
$lang->filter['invalid_extension'] = '%s의 형식이 잘못되었습니다. gif, jpg, png 등 쉼표로 구분하여 입력해야 합니다.';
$lang->security_invalid_session = '바르지 않은 접근입니다. 인증을 위해 다시 로그인해야 합니다.';
$lang->security_warning_embed = '보안 문제로 관리자 아이디로는 embed를 볼 수 없습니다. 확인하려면 다른 아이디로 접속하세요';
$lang->msg_baseobject_fix = 'Object → BaseObject 변환이 필요한 서드파티 자료가 있습니다. 위의 에러 메시지에 포함된 파일명과 줄 번호를 참고하여 수정하세요.';
$lang->msg_pc_to_mobile = '모바일에 최적화된 화면으로 보기';
$lang->cmd_yes = '예';
$lang->cmd_no = '아니오';
@ -380,4 +381,4 @@ $lang->image_quality = '화질';
$lang->standard = '표준';
$lang->unlimited = '제한 없음';
$lang->admin = '관리자';
$lang->stop = '중지';
$lang->stop = '중지';