Skip to content

Add error code name to status error messages#126

Merged
murgatroid99 merged 3 commits into
grpc:v1.8.xfrom
murgatroid99:status_error_output_improvement
Jan 12, 2018
Merged

Add error code name to status error messages#126
murgatroid99 merged 3 commits into
grpc:v1.8.xfrom
murgatroid99:status_error_output_improvement

Conversation

@murgatroid99

Copy link
Copy Markdown
Member

We frequently get questions that reference status errors, but they almost never realize that the code is important or know what it means. This adds the status code number and name to the error message.

@murgatroid99
murgatroid99 requested a review from kjin December 15, 2017 19:12
let message = `${status.code} ${status.name}: ${status.details}`;
let error = new Error(message);
error.code = status.code;
error.details = status.details;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include error.metadata as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That is actually what I meant to write there. The details string is in the message. It probably doesn't need to be in a separate field too.

@kjin

kjin commented Dec 15, 2017

Copy link
Copy Markdown
Contributor

LGTM once tests are amended to reflect new message changes

@murgatroid99

Copy link
Copy Markdown
Member Author

I was lazy and didn't run the tests, so I didn't realized that I had so many tests that depended on the specific text of the error messages. I'll have to think about how to handle that.

@murgatroid99

Copy link
Copy Markdown
Member Author

My solution is to add a details string to the error objects that exactly matches the original details string, and check that in the tests.

@murgatroid99
murgatroid99 merged commit 28fcd46 into grpc:v1.8.x Jan 12, 2018
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants