def get_exception_for_uncaught_api_error(func, exc):
 if isinstance(exc, mongoengine.ValidationError):
  result = webob_exc.HTTPBadRequest(detail=exc.message)
  return result
 elif isinstance(exc, jsonschema.ValidationError):
  result = webob_exc.HTTPBadRequest(detail=exc.message)
  return result
 return exc

def get_exception_for_uncaught_api_error ( func , exc ) : if isinstance ( exc , mongoengine . ValidationError ) : result = webob_exc . HTTPBadRequest ( detail = exc . message ) return result elif isinstance ( exc , jsonschema . ValidationError ) : result = webob_exc . HTTPBadRequest ( detail = exc . message ) return result return exc
utility function which tries to map an uncaught exception throwed inside an api to a more user-friendly exception which is returned instead of returning internal server error .