GithubHelp home page GithubHelp logo

Comments (6)

assert6 avatar assert6 commented on August 20, 2024

博客的英文字体为啥大小写混乱啊😵

from blog.

overtrue avatar overtrue commented on August 20, 2024

@assert6 截图看看?

from blog.

wanghaida avatar wanghaida commented on August 20, 2024

一开始我也自定义了一个 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.

Lwzi avatar Lwzi commented on August 20, 2024

字里行间都是知识点啊。

from blog.

rainlam163 avatar rainlam163 commented on August 20, 2024

6

from blog.

savvym avatar savvym commented on August 20, 2024

学到了

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.