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

Relays and mailboxes #3

Merged
merged 88 commits into from
May 12, 2021
Merged

Relays and mailboxes #3

merged 88 commits into from
May 12, 2021

Conversation

pavlo-liapin
Copy link
Contributor

No description provided.

src/relay/relay.ts Outdated Show resolved Hide resolved
src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/nacl/js-nacl-driver.ts Outdated Show resolved Hide resolved
src/nacl/js-nacl-driver.ts Outdated Show resolved Hide resolved
src/relay/relay.ts Outdated Show resolved Hide resolved
return String(response.data);
} catch (e) {
console.log(e.response);
throw new Error('[Relay] Bad Response');
Copy link
Contributor

Choose a reason for hiding this comment

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

error will be same for every erro that axios returns No Connection, 5xx, 4xx. I propose to handle only this line return String(response.data);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm now throwing HTTP status there, so the client app can try a network call and catch 401, 404, 500 or whatever. Is it fine, or do you have better suggestions?

https://github.com/vault12/glow.ts/blob/relays-and-mailboxes/src/relay/relay.spec.ts#L28-L40

Copy link
Contributor

@lomchik lomchik May 11, 2021

Choose a reason for hiding this comment

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

i propose to throw new HttpErrorResponse(axiosError.response.status) we already handle it in vault12 https://github.com/vault12/vault12/blob/4fa0dc5d0e629c79d9ac6607c4d638258dbd443e/src/app/core/communication/network-retry-strategy/network-retry-strategy.ts#L119-L125 or just remove try catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, makes sense. I removed try-catch, let the library user decide what to do with errors

src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/nacl/nacl.ts Show resolved Hide resolved
src/nacl/nacl.ts Outdated Show resolved Hide resolved
src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/mailbox/mailbox.ts Outdated Show resolved Hide resolved
src/relay/relay.ts Outdated Show resolved Hide resolved
@pavlo-liapin pavlo-liapin merged commit d8ab120 into main May 12, 2021
@pavlo-liapin pavlo-liapin deleted the relays-and-mailboxes branch May 12, 2021 13:24
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.

3 participants