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

Try catch subscription handlers #1019

Merged
merged 3 commits into from
Dec 10, 2024
Merged

Try catch subscription handlers #1019

merged 3 commits into from
Dec 10, 2024

Conversation

nihalbhatnagar
Copy link
Contributor

No description provided.

@@ -45,7 +45,7 @@ export interface ObjectSetListener<
/**
* There was a fatal error with the subscription process. The subscription will close or will not be established.
*/
onError?: (errors: Array<any>) => void;
onError?: (errors: { subscriptionClosed: boolean; error: any }) => void;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Settled on a boolean here, the alternative was an enum to also be able to display the "I already tried to reconnect for you case" but I think that adds unnecessary complexity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe I need to make it isSubscriptionClosed?

sub.listener.onChange?.(osdkObject);
} catch (error) {
this.#logger?.error(error, "Error in onChange callback");
sub.listener.onError({ subscriptionClosed: false, error });
Copy link
Member

Choose a reason for hiding this comment

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

if an error happens while in onError the whole thing still breaks, no? We need a fallback in that case.

@nihalbhatnagar nihalbhatnagar merged commit cddc196 into main Dec 10, 2024
8 checks passed
@nihalbhatnagar nihalbhatnagar deleted the nihalb/osw-trycatch branch December 10, 2024 14:42
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.

2 participants