howto handle ajax errors

I was wondering if there is an official way to handle ajax errors in yii2. I can submit forms using ajax and if everything goes well in the action that handles the ajax call, I get a success response. However, when things don’t go according to plan (e.g. syntax error in the controller action), nothing happens on the sender view. So the question is: How do I configure the controller action to redirect the debug display from the controller and deal with it, for example by displaying it to the user in the view.


Get the firePHP extension for chrome and the yii2 firephp package via composer. Then, log all debug messages to the console.