I have a custom prediction routine in `google-ml-engine`. Works very well. 

I now am doing input checking on the instance data, and want to return error responses from my predict routine. 

The example: <https://cloud.google.com/ai-platform/prediction/docs/custom-prediction-routines>

Raises exceptions on input errors, etc. However, when this happens the response body always has `{'error': Prediction failed: unknown error}.` I can see the correct errors are being logged in google cloud console, but the https response is always the same `unknown error`. 

**My question is:** 

How to make the **Custom prediction routine** return a proper error code and error message string? 

Instead of returning a prediction, I can return an error string/code in prediction -but it ends up in the prediction part of the response which seems hacky and doesn't get any of the google errors eg based on instance size.

```
root:test_deployment.py:35 {'predictions': {'error': "('Instance does not include required sensors', 'occurred at index 0')"}}

```

What's the best way to do this?

Thanks!
David