-
Notifications
You must be signed in to change notification settings - Fork 86
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: return Google Error when there is a missing required parameter #1291
Conversation
src/fallbackServiceStub.ts
Outdated
request | ||
); | ||
} catch (err) { | ||
return Promise.resolve(callback(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.
This seems to be the right place to catch it.
I wonder if just doing if (callback) { callback(err); } return;
will do the trick without explicitly creating a promise here. Can you try that?
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 gave it a try, it didn't work!
src/fallbackRest.ts
Outdated
@@ -61,6 +61,10 @@ export function encodeRequest( | |||
rpc.parsedOptions, | |||
rpc.resolvedRequestType!.fields | |||
); | |||
if (transcoded instanceof GoogleError) { |
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.
Here I think it's pretty much the same as putting the call to transcode()
into try ... catch
, then we won't need to change its return value. It may or may not be cleaner.
Fixes #1203 |
src/fallbackRest.ts
Outdated
rpc.resolvedRequestType!.fields | ||
); | ||
} catch (err) { | ||
throw transcoded; |
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 finally got back to reviewing this. In line 68, you will throw undefined
if the transcode()
call failed, this does not seem right.
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.
Hm, the only way I can think to fix this is how I had it before, namely:
if (transcoded instanceof GoogleError) {
throw transcoded;
}
I think changing it to try-catch causes the problem you're describing.
No description provided.