Comments (6)
博客的英文字体为啥大小写混乱啊😵
from blog.
@assert6 截图看看?
from blog.
一开始我也自定义了一个 exception,但是感觉每次 throw 也有点麻烦,又因为前端信息展示没有那么复杂,我就直接修改了 Handler.php 的 render 方法:
public function render($request, Throwable $e)
{
if ($request->is('api/*')) {
$error = $this->convertExceptionToResponse($e);
$response = [
'success' => false,
'code' => $error->getStatusCode(),
'data' => null,
'message' => 'Server Error',
];
if (config('app.debug')) {
$response = array_merge($response, [
'message' => empty($e->getMessage()) ? 'Server Error' : $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(),
]);
}
return response()->json($response, $error->getStatusCode());
}
return parent::render($request, $e);
}
from blog.
字里行间都是知识点啊。
from blog.
6
from blog.
学到了
from blog.
Related Issues (20)
- Laravel 中如何更方便的修改 Passport Personal Access Token 过期时间 | overtrue
- PinYin库升级到4.0后所有拼音里有a的都无法转换!
- 一种 Laravel 中简单设置多态关系模型别名的方式 | overtrue
- 如何在 Ant Design Pro 或 UmiJS 中使用 tailwindcss | overtrue
- 关于 | overtrue HOT 3
- sudo -Hu 执行时找不到命令的问题解决 - overtrue
- PHPCS、PHPMD 的安装与配置 - overtrue HOT 1
- 让你的 Laravel 应用与官方保持同步 - overtrue HOT 8
- npm 代理安装依赖 - overtrue HOT 2
- 又一篇 Deployer 的使用攻略 - overtrue HOT 23
- Laravel 中如何更方便的修改 Passport Personal Access Token 过期时间 - overtrue HOT 3
- 我写了一份 PHP 拓展包开发教程 - overtrue HOT 2
- 一种 Laravel 中简单设置多态关系模型别名(Polymorphic Types)的方式 - overtrue
- 如何在 And Design Pro 或 UmiJS 中使用 tailwindcss - overtrue HOT 5
- 我写了一份 PHP 拓展包开发教程 | overtrue
- Laravel 中如何更方便的修改 Passport Personal Access Token 过期时间 | overtrue
- Hello | overtrue
- EasyWeChat 企业微信 HOT 1
- 我所理解的 PHP Trait | overtrue HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.