title: Yii2 and handling exceptions
body: <p>I'm building REST APi for my app, based on <strong>Yii2</strong>.
  So, i have a problem with dealing exceptions.
  For example i need to throw <strong>405 HTTP</strong> code when someone use wrong <strong>HTTP verb</strong>, but i wanna send back something like this:</p>
  
  <p><code>{meta:{error:{code:405,message:"Wrong method"}}}</code></p>
  
  <p>So, i need to catch <strong>Exception's</strong> and modify <strong>Response</strong> object. But how can i do this?
  In Yii there were <strong>onError</strong> and <strong>onException</strong> events. What about Yii2?</p>