update: error message

This commit is contained in:
tokumeikoi 2022-05-15 01:10:27 +08:00
parent fae48e2c81
commit 649c03c214
4 changed files with 33 additions and 6 deletions

View File

@ -3,7 +3,10 @@
namespace App\Exceptions; namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Arr;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable; use Throwable;
use Facade\Ignition\Exceptions\ViewException;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
@ -50,9 +53,27 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Throwable $exception) public function render($request, Throwable $exception)
{ {
if ($exception instanceof \Facade\Ignition\Exceptions\ViewException) { if ($exception instanceof ViewException) {
abort(501, '主题初始化发生错误,请在后台对主题检查或配置后重试。'); return response([
'message' => "主题初始化发生错误,请在后台对主题检查或配置后重试。"
]);
} }
return parent::render($request, $exception); return parent::render($request, $exception);
} }
protected function convertExceptionToArray(Throwable $e)
{
return config('app.debug') ? [
'message' => $e->getMessage(),
'exception' => get_class($e),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => collect($e->getTrace())->map(function ($trace) {
return Arr::except($trace, ['args']);
})->all(),
] : [
'message' => $this->isHttpException($e) ? $e->getMessage() : __("Uh-oh, we've had some problems, we're working on it."),
];
}
} }

View File

@ -28,9 +28,13 @@ class ThemeController extends Controller
} }
$data = var_export($data, 1); $data = var_export($data, 1);
try {
if (!File::put(base_path() . "/config/theme/{$themeName}.php", "<?php\n return $data ;")) { if (!File::put(base_path() . "/config/theme/{$themeName}.php", "<?php\n return $data ;")) {
abort(500, "{$themeName}初始化失败"); abort(500, "{$themeName}初始化失败");
} }
} catch (\Exception $e) {
abort(500, '请检查V2Board目录权限');
}
try { try {
Artisan::call('config:cache'); Artisan::call('config:cache');

View File

@ -88,5 +88,6 @@
"The coupon can only be used :limit_use_with_user per person": "The coupon can only be used :limit_use_with_user per person", "The coupon can only be used :limit_use_with_user per person": "The coupon can only be used :limit_use_with_user per person",
"The coupon code cannot be used for this period": "The coupon code cannot be used for this period", "The coupon code cannot be used for this period": "The coupon code cannot be used for this period",
"Request failed, please try again later": "Request failed, please try again later", "Request failed, please try again later": "Request failed, please try again later",
"Register frequently, please try again after 1 hour": "Register frequently, please try again after 1 hour" "Register frequently, please try again after 1 hour": "Register frequently, please try again after 1 hour",
"Uh-oh, we've had some problems, we're working on it.": "Uh-oh, we've had some problems, we're working on it."
} }

View File

@ -88,5 +88,6 @@
"The coupon can only be used :limit_use_with_user per person": "该优惠券每人只能用 :limit_use_with_user 次", "The coupon can only be used :limit_use_with_user per person": "该优惠券每人只能用 :limit_use_with_user 次",
"The coupon code cannot be used for this period": "此优惠券无法用于该付款周期", "The coupon code cannot be used for this period": "此优惠券无法用于该付款周期",
"Request failed, please try again later": "请求失败,请稍后再试", "Request failed, please try again later": "请求失败,请稍后再试",
"Register frequently, please try again after 1 hour": "注册频繁请等待1小时后再次尝试" "Register frequently, please try again after 1 hour": "注册频繁请等待1小时后再次尝试",
"Uh-oh, we've had some problems, we're working on it.": "遇到了些问题,我们正在进行处理"
} }