OpenLiberty / guide-rest-intro

An introductory guide on how to create a REST application using Java EE running on Open Liberty: http://www.openliberty.io/guides/rest-intro.html
Other
19 stars 47 forks source link

Consider providing guidance on exception handling #49

Open lmsurpre opened 6 years ago

lmsurpre commented 6 years ago

I used this guide to refresh my JAX-RS knowledge. Unfortunately, when I went to apply that, I was getting a 500 error back in my client but there was nothing useful in the server logs (even with debug tracing).

It turned out to be a dumb mistake on my part (ArrayOutOfBoundsException), but is there a suggested way for configuring a root exception handler so that future mistakes like that would at least get logged?

I ended up following the advice at https://stackoverflow.com/a/19680115/161022 to register an ExceptionMapper and inserted a log statement there. If that is the recommended approach, it might be nice to add something like that to this guide so that anyone starting from here will have unhandled exceptions logged for them. Let me know if I'm missing something!

AustinSeto commented 4 years ago

When running the application included in the guide using the goal mvn liberty:run or mvn liberty:dev logs are created in the directory target/liberty/wlp/usr/servers/defaultServer/logs. Errors appear in .log files generated there.

May be worth it to mention these logs, but this probably isn't a good way to handle this. Unsure if exception handling should be included in the intro guide or if it should be in its own guide.