I’m serving REST API which need to return JSON format error messages along with normal functionality with Yii, I specified an error handler in config/main.php to make customized error page, but this applies globally.
Is there anyway I can use a specific error handler in api controller to throw JSON error message instead of default error page?