开启调试模式 .env

APP_DEBUG = true

异常页面的模板文件 config/app.php

'exception_tmpl'   => app()->getThinkPath() . 'tpl/think_exception.tpl'

手动抛出异常

// 使用think自带异常类抛出异常
throw new \think\Exception('异常消息', 10006);

手动捕获异常

try {
    // 这里是主体代码
} catch (ValidateException $e) {
    // 这是进行验证异常捕获
    return json($e->getError());
} catch (\Exception $e) {
    // 这是进行异常捕获
    return json($e->getMessage());
}

相关文章:

  • 2021-09-04
  • 2022-02-27
  • 2021-12-18
猜你喜欢
  • 2021-04-05
  • 2021-06-12
  • 2021-11-13
  • 2022-12-23
  • 2021-12-12
  • 2021-07-28
  • 2022-12-23
相关资源
相似解决方案