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

Allow extension or overwrite of error handling behaviour to allow custom errors to bubble up #1430

Open
p-mercury opened this issue Feb 19, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@p-mercury
Copy link

Is your feature request related to a problem? Please describe.
I am using the connect RPC client in a Sveltekit applications and on the client transport I have an authentication interceptor. The interceptor manages the access token, adding it to the requests Authorization header if it is valid, but if the token is expired or not present the interceptor throws a redirect error as documented for Sveltekit.

The problem is that currently this redirect error gets converted to a connect error by the setupSignal function which prevents the Sveltekit behaviour of redirecting when this error is detected. This seems like a reasonable use case and is currently not possible.

Describe the solution you'd like
I am not sure what the best way to implement this features is, but two options would be:

  • A transport option to prevent error conversion
  • A transport option that allows you to extend the error handling behaviour

Describe alternatives you've considered
This is the only way I see this currently working, but this defeats the purpose of the interceptor if on every call I need to manually add error handling.

try {
    await client.identity.listAccounts({});
  } catch (err) {
    if (err instanceof ConnectError && isRedirect(err.cause)) {
      throw err.cause;
    }
    throw err;
  }
@p-mercury p-mercury added the enhancement New feature or request label Feb 19, 2025
@timostamm
Copy link
Member

It wasn't possible to use cause for a long time, but it's widely available now. We've filed sveltejs/kit#13487, asking whether they're open to support cause when looking for a redirect error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants