-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(presto-client): return back the whole error object #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering, Does it worth adding an example of an endpoint which fails to the Nest.js example application?
Good idea @jorgeramirezamora , I'll include an example of using the returned error 👍 |
I believe the error handling is deviating from the documentation. But the doc update could come later :-) LGTM |
I created an interface for PrestoError but I'm now thinking that it should be a class, so that you can do catch (error) {
if (error instanceof PrestoError) { ... }
} so I'll take some time to refactor that |
if (error instanceof PrestoError) { | ||
/* eslint-disable no-console */ | ||
// The error here contains all the information returned by Presto directly | ||
console.info(error.message) | ||
console.info(error.name) | ||
console.info(error.errorCode) | ||
console.info(error.stack) | ||
console.info(error.failureInfo.type) | ||
return 'A Presto error ocurred, please check the service logs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this example usage in the app to better showcase how to use the returned error
try { | ||
return await this.appService.getDataWithError() | ||
} catch (err) { | ||
console.error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this would be an error other than PrestoError because the PrestoError is handled in the getDataWithError
and no rethrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I guess I'm using the service file as the showcase for the error
I don't know if we should also do something else here in the controller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
const prestoQuery = await client.query(query) | ||
const results = prestoQuery.data | ||
} catch (error) { | ||
if (error instanceof PrestoError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice!
Changes
Resolves #11