You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allow to have the original CodeException message but not it's stacktrace , so information are loose
instead, PHP already have a builtin mechanism for that , which is the previous: Exception $e parameter in Exception constructors which allow to do the following construction (adminting you don't override the constructor
allow you to not have to reconstruct a "original message : %s"
(One short paragraph is enough)
Example of how to use this feature (Show some PHP code and/or YAML config explaining how to use this feature in a real app)
transform
finalclass EntityRemoveException extends BaseException
{
publicfunction__construct(array$parameters = [])
{
$exceptionContext = newExceptionContext(
'exception.entity_remove',
sprintf('There is a ForeignKeyConstraintViolationException for the Doctrine entity associated with "%s". Solution: disable the "delete" action for this CRUD controller or configure the "cascade={"remove"}" attribute for the related field in the Doctrine entity. Full exception: %s', $parameters['entity_name'], $parameters['message']),
$parameters,
409
);
parent::__construct($exceptionContext);
}
}
into
finalclass EntityRemoveException extends BaseException
{
publicfunction__construct(string$entityName, Exception$previous)
{
$exceptionContext = newExceptionContext(
'exception.entity_remove',
sprintf('There is a ForeignKeyConstraintViolationException for the Doctrine entity associated with "%s". Solution: disable the "delete" action for this CRUD controller or configure the "cascade={"remove"}" attribute for the related field in the Doctrine entity.', $parameters['entity_name']),
$parameters,
409
);
parent::__construct($exceptionContext, previous $previous);
}
}
@allan-simon fantastic and detailed explanation! Thanks a lot Allan. Yes, I think that your proposal makes a lot of sense. If you can make a PR as you proposed, that would be even more amazing. Thanks a lot!
Short description of what this feature will allow to do:
It will allow to have a more precise context of the original exception
Currently for
EntityRemoveException
(and certainly other exception in easyadmin bundle) the usage is the followingi.e
This allow to have the original CodeException message but not it's stacktrace , so information are loose
instead, PHP already have a builtin mechanism for that , which is the
previous: Exception $e
parameter in Exception constructors which allow to do the following construction (adminting you don't override the constructorThis allow to
(One short paragraph is enough)
Example of how to use this feature
(Show some PHP code and/or YAML config explaining how to use this feature in a real app)
transform
into
so that you could then do
The text was updated successfully, but these errors were encountered: