api-platform icon indicating copy to clipboard operation
api-platform copied to clipboard

exception_to_status and monolog's excluded_http_codes

Open temp opened this issue 1 year ago • 2 comments

It seems like exception_to_status and monolog's excluded_http_codes in the fingers crossed handler don't work together. We have mapped a ItemNotFound exception to 404 in exception_to_status, and we have excluded 404's from monolog via fingers crossed / excluded_http_codes. But the exception is still processed in monolog. Anything I can do to prevent this? Or do I have to catch the exception and throw a HttpException? Which would render exception_to_status useless...

temp avatar Feb 04 '25 12:02 temp

There is maybe a problem with listener priorities? Monolog is likely executing before the API Platform listener.

dunglas avatar Feb 04 '25 14:02 dunglas

Not sure why, check here: https://github.com/api-platform/core/blob/main/src/Symfony/EventListener/ErrorListener.php#L87 can you open an issue on api-platform/core with a bit more details, we don't touch the monolog configuration.

soyuka avatar Feb 07 '25 15:02 soyuka