I am creating a REST APi for my Yii2 based application . So, I have a problem with exception handling. For example, I need to throw out HTTP 405 code when someone uses the wrong HTTP verb , but I want to send something like this:
{meta:{error:{code:405,message:"Wrong method"}}}
So, I need to catch the Exception and modify the Response . But how can I do this? Yii had onError and onException events . What about Yii2?
source
share