Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate异常不使用助手函数的话,怎么返回400呢,根据文档扩展自己的 Handler 好像也没有生效 #6

Closed
inccleo opened this issue Jan 17, 2023 · 1 comment

Comments

@inccleo
Copy link

inccleo commented Jan 17, 2023

No description provided.

@inccleo inccleo changed the title Validate异常不使用助手函数的话,怎么返回400呢,根据文档自定义一个自己的异常类好像没有生效 Validate异常不使用助手函数的话,怎么返回400呢,根据文档扩展自己的 Handler 好像也没有生效 Jan 17, 2023
@Tinywan
Copy link
Owner

Tinywan commented Jan 17, 2023

扩展自己的 Handler 好像也没有生效。具体代码粘贴一下

我这边都是没问题的

class ExceptionHandler extends Handler
{
    /**
     * @desc: 重写处理扩展的异常,增加自己的异常
     * @param Throwable $e
     * @author Tinywan(ShaoBo Wan)
     */
    protected function solveExtraException(Throwable $e): void
    {
        // 用户中心异常处理
        if ($e instanceof \ErrorException) {
            $this->errorMessage = '用户中心异常:'.$e->getMessage();
            $this->errorCode = 400;
            return;
        }
        parent::solveExtraException($e);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants