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

v4: Error notifying library and halting #225

Open
diamondburned opened this issue Jun 10, 2021 · 2 comments
Open

v4: Error notifying library and halting #225

diamondburned opened this issue Jun 10, 2021 · 2 comments
Labels
enhancement New feature or request flaw Bugs that require a breaking change
Milestone

Comments

@diamondburned
Copy link
Owner

For v3, we should add a library that allows the library users to intercept internal errors (especially ones that are automatically handled). This will allow the user to intercept and halt instances that might try to recover itself from unrecoverable situations, such as when a token is invalidated.

The basic API of this library is listed below:

type NotifiedFunc func(err error) (ok bool)

type Notifier interface {
    Notify(err error) (ok bool)
    AddNotifiedFunc(fn NotifiedFunc)
}

In this API, the NotifiedFunc function will be called on every internal error. If the function returns false in the chain, then the whole operation must be stopped and cleaned up. This is because by returning false, the user is suggesting that the error indicates an unrecoverable state.

Ideally, the library can handle this internally, but adding handlers for every single edge case is not completely feasible, so flexibility should be preferred.


As a sidenote, the API would be a lot more reasonable if Open() is blocking, since it would allow the user to handle unexpected cases without needing to rely on weird callbacks that are potentially racy; I can make a separate issue for this if there's not a good use case for a non-blocking Open().

@diamondburned
Copy link
Owner Author

Ideally, this should completely replace all ErrorLog{,ger} fields and the wsutil.WSError global variable.

@diamondburned diamondburned added enhancement New feature or request flaw Bugs that require a breaking change labels Jun 30, 2021
@diamondburned diamondburned changed the title v3: Error notifying library and halting v4: Error notifying library and halting Oct 13, 2022
@diamondburned
Copy link
Owner Author

Moved to v4.

@diamondburned diamondburned added this to the v4 milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request flaw Bugs that require a breaking change
Projects
None yet
Development

No branches or pull requests

1 participant