If you use JavaScript client, JSONP callbacks to work you need always send a status of 200.
So REST API sends a status code of 200 even when your request failed.
You can add the HTTP status in a error JSON object or you can set a custom HTTP header using responseProperties.
For instance:
responseProperties = "{
- \"Content-Type\" : \"
application/pdf
\", - \"X-HTTP-Status\" : \"500 - An error occurred while generating the pdf file.\"
- }";