Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
breaking: tighten up error handling #11289
breaking: tighten up error handling #11289
Changes from 14 commits
64565c0
fddc54f
7613649
5bf57fb
34acad2
ae79081
067c3fa
43e7d2e
a5da208
8f0fbab
6d77aa5
c1c280c
da81262
e4c96b7
e5ad6f1
a291b70
f75abdc
bbe2c5d
7f5df13
877605f
99b54e4
824198d
7ecbca5
24bdfd9
c1265d8
452e264
5a914a2
95bb358
b24e8eb
d31afbb
231f212
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might not be clear what "unexpected error" here refers to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't this use
SvelteKitError
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think an error at this stage will be handled by
handelError
, so I kept this clear of it. But we could use it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at this stage, no. But the thing that reads the body will either catch the error (in which case it is then responsible for setting a status code) or, more likely, the error will go uncaught. At that point, it's useful if the error was a
SvelteKitError
with a correct status code. If it's a POJO thenhandleError
will be called with a 500 Internal Error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More correctly: the above applied to the second occurrence, once the stream has already started being read.
In this case, we're still creating the
Request
object. Right now, every usage ofgetRequest
has to be wrapped in atry-catch
, and thecatch
clause always looks like this:This makes no sense — there's only one possible error (the 413), and the diagnostic message gets swallowed.
I think the best solution is to throw the 'content length exceeds limit' error immediately when the stream starts. That way,
getRequest
callers don't need totry-catch
, and we get both user-friendly and developer-friendly error messages.