When Apify returns error messages, it does so in your requested format.
An error from a JSON request might look like this:
class UsersController extends Controller
{
    public function indexAction($request)
    {
        $request->acceptContentTypes(array('json', 'xml'));
    	$response = new Response();
        if (! $request->hasParam('api_key')) {
            throw new Exception('Missing parameter: api_key', Response::FORBIDDEN);
        }
        $response->api_key = $request->getParam('api_key');
        return $response;
    }
}
HTTP Request
GET /users.json
Response
Status: 403 Forbidden
Content-Type: application/json
{
    "code": 403,
    "error": {
        "message": "Missing parameter: api_key",
        "type": "Exception"
    }
}
Comments
Use this form to add corrections, additions and suggestions about the documentation on this page. If you encounter any problems, please use the GitHub issue tracker.