-
Notifications
You must be signed in to change notification settings - Fork 44
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
Provide a better error message when an unknown error occurs in deployment #304
Conversation
350466f
to
5d2020c
Compare
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, one question though
src/lib/deploy.js
Outdated
@@ -419,7 +419,7 @@ async function deploy({ alias, yes }) { | |||
|
|||
if (!txn || txn?.kind === 'error') { | |||
// Note that the thrown error object is already console logged via step(). | |||
log(red(getErrorMessage(txn.message ?? []))); | |||
log(red(getErrorMessage(txn?.message ?? []))); |
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 an improvement, but I wonder if there's additional benefit in also looking at the statusCode
and statusText
(see what sendGraphQL returns) for potential info if the txn.message
is not an array of errors. Also, I wonder if there could be more info in the responseJson
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.
That's a good point! Should we just dump the returned json if they are no array of errors to report on? On one hand, giving an Unknown error
message is better than a runtime error but I would like to have more traceability in errors when they do occur.
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!
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!Thanks for adding this!
We think logging the malformed error to the console is a good idea |
Use the util.format built-in to format the error receieved inside getErrorMessage(). This gives us better logging and discoverability when an unknown error occurs. By using util.format, we get the message and stack properties in the log output.
Description
Addresses #255 when a deployment fails with an error response that is not in the form we expect. When a GraphQL error occurs, we expect an array of errors to be returned from the endpoint we are issuing. When an error returns that's not an array, an unhelpful message is shown along the lines of:
This PR makes a change to log
Failed to send transaction. Unknown error
if such an error occurs instead.