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

Please do not coerce errors #28

Open
snnsnn opened this issue Apr 19, 2024 · 2 comments · May be fixed by #29
Open

Please do not coerce errors #28

snnsnn opened this issue Apr 19, 2024 · 2 comments · May be fixed by #29

Comments

@snnsnn
Copy link

snnsnn commented Apr 19, 2024

function handleError(scope: Scope | null, error: unknown) {

Once we had a discussion on keeping the language semantics when handling errors in SolidJS. Solid did not allow throwing falsy values as errors even though the language permits it. I see you follow somewhat similar path, but coercing errors may not be good idea from the consumer's perspective. Why not keep them as is:

let handled = false;
for (let i = 0, len = handlers.length; i < len; i++) {
  try {
    handlers[i](error);
    handled = true;
    break; // Error is handled.
  } catch (rethrown: any) {
    error = rethrown;
  }
}
if (!handled) throw error;

Is there a valid reason for coercion?

@mihar-22
Copy link
Member

Good point, let's remove it. Can't remember why but we shouldn't mess with it. Happy to pull in a PR. It's breaking change so we'll need to bump to v6.

@snnsnn
Copy link
Author

snnsnn commented Apr 19, 2024

Good point, let's remove it. Can't remember why but we shouldn't mess with it. Happy to pull in a PR. It's breaking change so we'll need to bump to v6.

Ok. It is coming..

@snnsnn snnsnn linked a pull request Apr 19, 2024 that will close this issue
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 a pull request may close this issue.

2 participants