ShopApiPlugin
ShopApiPlugin copied to clipboard
Handle general exceptions at one place
I am wondering if extracting error handling of exceptions like ChannelNotFoundException
as generic approach for the shop api would be suitable. At the moment every resource handles on its own such stuff.
if some api needs another kind of handling f.e. ChannelNotFoundException
the developer has to implement it on its own.
I have implemented a very straight forward approach under the assumption that if the channel can not be found then the route does not exist (in our case this means that the hostname does not resolve to a channel). Then the local thing is to return a 404.
This we did with an event listener listening to kernel.exception
. And then handling the stuff accordingly.