add error handling to expose exceptions in resource code

Currently, unhandled exceptions in resource code gets squashed, with not visibility into the error.  This adds a debug message and returns a 500 with the error and stack trace.