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
Feature/pub 71 add error handler #75
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.
LGTM with some nitpicks regarding defaults
public static handleError(error: Error): void { | ||
// default error handling logic | ||
Logger.Instance.error({ error }, 'Received Unexpected Error'); | ||
} |
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.
Let's rethrow the error in the default handler, so application can handle it on their own
public static handleError(error: Error): void { | |
// default error handling logic | |
Logger.Instance.error({ error }, 'Received Unexpected Error'); | |
} | |
public static handleError(error: Error): void { | |
// default error handling logic | |
Logger.Instance.error({ error }, 'Received Unexpected Error'); | |
throw error; | |
} |
handleError: function(error: Error): void { | ||
// internal error handling logic for subscriber | ||
} |
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.
Let's add an example similar to google docs: https://googleapis.dev/nodejs/pubsub/latest/index.html#using-the-client-library
handleError: function(error: Error): void { | |
// internal error handling logic for subscriber | |
} | |
handleError: function(error: Error): void { | |
// internal error handling logic for subscriber | |
console.error('Subscription error', error); | |
// shutdown any connections here and exit | |
process.exit(1); | |
} |
Similar handlers in other examples also
PUB-71: