Skip to content

Expose exception severity in data bag #1338

Description

@kkmuffme

Atm, the ExceptionDataBag does not include the exception's severity and it's not possible to get it either, since the exception itself is not in the DataBag too

It would be incredibly useful if either the original exception itself or at least the $exception->getSeverity() were available in the data bag for further, custom processing.

My use case:
in setBeforeSendCallback I'd like to overwrite the type: "ErrorException", with a custom string, depending on if the error is a PHP native error (E_NOTICE) or comes from a user triggered error (E_USER_NOTICE)
Atm I have to strpos the context_line for USER NOTICE, which is not very robust and leads to quite a few false positives unfortunately.

e.g. simplified:

function ( \Sentry\Event $event ) {
	$exceptions = $event->getExceptions();
	$raw_exception = $exceptions[0]->getException(); // @todo this is what I woudl be ideal, a getSeverity() on it would be fine though
	if ( $raw_exception->getSeverity() === \E_USER_NOTICE ) {
		$exceptions[0]->setType( 'E_USER_NOTICE' ); // @todo ExceptionDataBag.php also needs a setType method added
	}
	
	return $event;	
}

On a side notee: since we use Sentry.io should I open a support ticket with them for faster processing of this request?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions