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

[8.x] Check for context method #36424

Merged
merged 1 commit into from
Mar 2, 2021
Merged

[8.x] Check for context method #36424

merged 1 commit into from
Mar 2, 2021

Conversation

avrahamappel
Copy link
Contributor

@avrahamappel avrahamappel commented Mar 1, 2021

Currently, in order to send custom context to the logger on a per-exception basis, it is necessary to override the exceptionContext method in App\Exceptions\Handler and check the exception instance. This PR enables the base Handler to detect a context method defined on the exception class which would return an array, keeping the context logic within the exception class.

class InvalidOrderException extends Exception
{
    /**
     * Provide exception context.
     *
     * @return array
     */
     public function context()
     {
         return ['id' => $this->order->id];
     }
}

Once this is merged, I can make a PR to the docs demonstrating this.

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.

None yet

2 participants