-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Describe the problem
#11278 sent me down a rabbit hole of error handling once more. It occured to me that us throwing errors is not correct, strictly speaking. Someone could've enhanced the App.Error object which means that more properties than just message are required, and as such calling error with just a string is wrong.
Describe the proposed solution
Instead of using error, we distinguish between unforseen fatal errors and not-so-bad errors by expanding on what was introduced in #11131:
- We create a
NonFatalErrorwithstatusandmessage(andNotFoundintroduced in that PR would go away) handleErroris called with those, too, but our fallback uses themessageverbatim in that case (because we know it doesn't contain sensitive information)- We expose that class through
@sveltejs/kitso people can doinstanceof NonFatalErrorinhandleErrorand inspect the status/message (would also make More information about error in HandleServerError #6774 more clear)/not send this to an error reporting service in that case - If
NonFatalErroris discovered, thestatusis not500but instead the one defined in the instance
Alternatives considered
Leave this as is and document this somewhere in the code base
Importance
would make my life easier
Additional Information
Putting this on the 2.0 milestone because if we change this it could be seen as a breaking change (things appearing in handleError differently)
teemingc