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

Add method to be able to override the exception context format #44895

Merged

Conversation

halnique
Copy link
Contributor

This PR extracted 1 protected methods to Illuminate\Foundation\Exceptions\Handler to override exception context format in downstream.

Currently if you need to customize context format of an exception, you would need to override the whole report method and do it there.

Adding this method allows us to customize context format of an exception by simply implementing the method in the applications Handler class. This is not a breaking change.

Example:

    // override
    protected function buildContext(Throwable $e): array
    {
        return [
            'exception' => [
                'origin' => $e,
                'context' => [
                    'common' => $this->context(),
                    'specific' => $this->exceptionContext($e),
                ],
            ],
        ];
    }

@taylorotwell taylorotwell merged commit 527b288 into laravel:9.x Nov 10, 2022
@halnique halnique deleted the feat/exception-handler-context-format branch November 11, 2022 01:14
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

Successfully merging this pull request may close these issues.

2 participants