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

Use Result type and throw fewer errors in Client and Core #1277

Merged
merged 29 commits into from
Sep 27, 2022

Conversation

krisbitney
Copy link
Contributor

@krisbitney krisbitney commented Sep 26, 2022

This PR replaces most thrown errors in the client and core with the Result pattern. Notably, client.invoke now returns a Result<TData, Error>.

Closes #1018, #1245

@lgtm-com
Copy link

lgtm-com bot commented Sep 26, 2022

This pull request fixes 1 alert when merging 86caf5a into 3cb0263 - view on LGTM.com

fixed alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Sep 26, 2022

This pull request fixes 1 alert when merging ca10282 into 3cb0263 - view on LGTM.com

fixed alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Sep 26, 2022

This pull request fixes 1 alert when merging fa6c52d into 3cb0263 - view on LGTM.com

fixed alerts:

  • 1 for Useless assignment to local variable

dOrgJelli
dOrgJelli previously approved these changes Sep 26, 2022
@lgtm-com
Copy link

lgtm-com bot commented Sep 26, 2022

This pull request fixes 1 alert when merging 657b2da into 3bf6502 - view on LGTM.com

fixed alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Sep 26, 2022

This pull request fixes 1 alert when merging 6ab5736 into 3bf6502 - view on LGTM.com

fixed alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Sep 26, 2022

This pull request fixes 1 alert when merging ae28dc1 into 3bf6502 - view on LGTM.com

fixed alerts:

  • 1 for Useless assignment to local variable

@@ -202,7 +215,7 @@ export class PolywrapClient implements Client {
>(options: QueryOptions<TVariables, TUri>): Promise<QueryResult<TData>> {
let result: QueryResult<TData>;

try {
err: try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious here: What's the reason for this syntax? I am noticing that you are then using a break but we can also return { errors: [parseResult.error as Error] }? Probably I am wrong but just wanted to understand this :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because of the clearContext below the try catch statement. I wanted to be sure it still ran since it was running on error before the changes.

cbrzn
cbrzn previously approved these changes Sep 27, 2022
Copy link
Contributor

@cbrzn cbrzn left a comment

Choose a reason for hiding this comment

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

This is super cool :) Feel free to ignore my comments

expect(response.data).toBeDefined();
expect(response.data).toBe(true);
if (!response.ok) fail(response.error);
expect(response.value).toBeDefined();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one is redundant

@nerfZael
Copy link
Contributor

@krisbitney PR looks awesome! I left a couple comments and there's some minor fixes in this PR: #1285

@lgtm-com
Copy link

lgtm-com bot commented Sep 27, 2022

This pull request fixes 1 alert when merging af0d730 into 3bf6502 - view on LGTM.com

fixed alerts:

  • 1 for Useless assignment to local variable

@dOrgJelli dOrgJelli merged commit dadd0f8 into origin-dev Sep 27, 2022
@dOrgJelli dOrgJelli deleted the use-result-client-core branch April 10, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Result type from @polywrap/result instead of InvokeResult Client: Throw Less Errors
4 participants