Closed dkelosky closed 4 years ago
Trying this out, I added a line to the GreetingController
: throw new Exception("I'm a failure");
In the log I get the stack trace:
java.lang.Exception: I'm a failure
at org.zowe.sample.apiservice.greeting.GreetingController.greeting(GreetingController.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
...
I get this API response from this:
{"messages":[{"messageKey":"org.zowe.commons.rest.internalServerError","messageType":"ERROR","messageNumber":"ZWEAS500","messageContent":"The service has encountered a situation it doesn't know how to handle. Please contact support for further assistance. More details are available in the log under the provided message instance ID","messageInstanceId":"9dea2819-1d5f-439e-8020-fb44888f44ae"}]}
Does this capture what you were asking?
BTW, the sample also has an endpoint for throwing a RuntimeException
already without code changes via /api/v1/greeting/failed
with the same behavior as above.
With this information, we know what output (and log details) a customer will see if an exception is not handled. Thanks.
Thank you
The API doc states: "Unexpected errors does not need to be handled or caught by your REST controller. If your controller throws an Exception or RuntimeException then Spring exception handler (customized by CustomRestExceptionHandler in the commons library) will convert the exception into a standardized format. "
Is information available on what content is produced by the commons package for an uncaught exception? For example, does it produce a stack trace, or other detailed information?
Reported by @gejohnston