Skip to content
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

fix: decode Http error using proto3-JSON-serializer #1273

Merged
merged 5 commits into from
May 25, 2022

Conversation

summer-ji-eng
Copy link
Contributor

@summer-ji-eng summer-ji-eng commented May 25, 2022

Using proto3-json-serializer to parse HTTP error json; example error return from http request:

const json = {
      error: {
        code: 403,
        message:
          'Cloud Translation API has not been used in project 123 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/translate.googleapis.com/overview?project=455411330361 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.',
        status: 'PERMISSION_DENIED',
        details: [{
'@type': 'type.googleapis.com/google.rpc.ErrorInfo',
      reason: 'SERVICE_DISABLED',
      domain: 'googleapis.com',
      metadata: {
        service: 'translate.googleapis.com',
        consumer: 'projects/123',
      },}],
      },
    };

Example of error.statusDetails

example before after
-- statusDetails: [ {'@type': 'type.googleapis.com/google.rpc.ErrorInfo',metadata: [Object],reason: 'SERVICE_DISABLED', domain: 'googleapis.com'}] statusDetails: [ErrorInfo {metadata: [Object], reason: 'SERVICE_DISABLED', domain: 'googleapis.com'}]

@summer-ji-eng summer-ji-eng requested a review from a team as a code owner May 25, 2022 06:16
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label May 25, 2022
@summer-ji-eng
Copy link
Contributor Author

I am getting lazy to fix the Typescript Type linter issue in this PR since it raise up along with the build. But please let me know if we need to split into another PR. Thank you @alexander-fenster .

@alexander-fenster
Copy link
Contributor

It's OK to have it here. Thank you!

@summer-ji-eng summer-ji-eng merged commit 17a790f into main May 25, 2022
@summer-ji-eng summer-ji-eng deleted the http_error_parse branch May 25, 2022 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants