You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would love to see an opinionated standardized error handling for SvelteKit.
For a year we have been building a B2B application with SvelteKit and IMHO it is missing a default/standard error object. In my view there are 3 kinds of errors that usually occur when using a shadow endpoint (sorry for old naming):
Network not working
Server not working (e.g. status 500)
Input not working
It would be great to be able to handle all of those errors with a single default/standard error object.
Please be aware that besides the simple Twitter demos with a single input field and no error handling there are indeed some real applications out there. Those need multiple input fields, so can have multiple errors. Furthermore they need to do client and also server side validation to ensure data is not tampered with.
Describe the proposed solution
I would like to see a default/standard error object for the 3 cases mentioned above.
This is just an idea, this is not a real proposal. If no error, the error object is null or should not exist.
Network error error: { status: '-1', name: 'NETWORK_ERROR', msg: 'Server could not be reached' }
Server error error: { status: '500', name: 'HTTP_SERVER_ERROR', msg: 'Server returned internal error' }
Case 3 doesn't really work that way because there might be multiple input errors. Furthermore the error object should be able to provide additional fields, for example the input field names
The first two should be handled by the new error method which you throw. You can pass it a status and a message. The third one would be handled as part of the forms proposal.
I'm not sure some fixed subset of errors is valuable since use cases vary too much. Couldn't you create your own error helpers for reuse in the project?
Describe the problem
I would love to see an opinionated standardized error handling for SvelteKit.
For a year we have been building a B2B application with SvelteKit and IMHO it is missing a default/standard error object. In my view there are 3 kinds of errors that usually occur when using a shadow endpoint (sorry for old naming):
It would be great to be able to handle all of those errors with a single default/standard error object.
Please be aware that besides the simple Twitter demos with a single input field and no error handling there are indeed some real applications out there. Those need multiple input fields, so can have multiple errors. Furthermore they need to do client and also server side validation to ensure data is not tampered with.
Describe the proposed solution
I would like to see a default/standard error object for the 3 cases mentioned above.
This is just an idea, this is not a real proposal. If no error, the error object is null or should not exist.
error: { status: '-1', name: 'NETWORK_ERROR', msg: 'Server could not be reached' }
error: { status: '500', name: 'HTTP_SERVER_ERROR', msg: 'Server returned internal error' }
error: { status: '200', name: 'FORM_INPUT_ERROR', msg: 'Invalid input' }
Case 3 doesn't really work that way because there might be multiple input errors. Furthermore the error object should be able to provide additional fields, for example the input field names
Input error (with input field name)
error: { status: '200', name: 'FORM_INPUT_ERROR', msg: 'Invalid input', props: { input: 'email' } }
Input error (with input field name, multiple errors)
Alternative input error (with input field name, multiple errors) [not my favourite]
Again, those are just some initial thought to get a discussion started.
Alternatives considered
No response
Importance
would make my life easier
Additional Information
I thought it's a good idea to bring this up now as the shadow endpints are re-worked anyway
The text was updated successfully, but these errors were encountered: