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

FileLoader: Add response to error object. #24296

Merged
merged 2 commits into from
Jul 18, 2022
Merged

Conversation

JacobMuchow
Copy link
Contributor

@JacobMuchow JacobMuchow commented Jun 30, 2022

Fixed #24295

Description

If a non-200 HTTP status is received in the FileLoader, I would like to have a safer way to check that then checking the error message text.

I added a custom HttpError type that adds an extra property to include the fetch Response object in the Error object. This seems like the best way to let devs do as they wish when this happens.

This is backwards compatible, and I tested by linking my local branch of three to my project

Also I ran lint-fix on everything hence the changes in the extra files.

@JacobMuchow
Copy link
Contributor Author

Should I include my company in the description? They are paying me lol

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 1, 2022

Do you mind rebasing your PR? The PR diff shows many unrelated changes.

Should I include my company in the description?

Do whatever you think it's best. The section This contribution is funded by... is intended for this purpose.

@Mugen87 Mugen87 changed the title Surface fetch Response object in Error when non-200 HTTP status is received FileLoader: Add response to error object. Jul 1, 2022
src/loaders/HttpError.js Outdated Show resolved Hide resolved
@JacobMuchow
Copy link
Contributor Author

Do you mind rebasing your PR? The PR diff shows many unrelated changes.

Yeah I can do that. Those changes came from the linter. I'll remove them.

src/loaders/FileLoader.js Outdated Show resolved Hide resolved
@Mugen87 Mugen87 added this to the r143 milestone Jul 10, 2022
@Mugen87 Mugen87 merged commit f5e2d49 into mrdoob:dev Jul 18, 2022
@mrdoob
Copy link
Owner

mrdoob commented Jul 27, 2022

Thanks!

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
* Surface fetch Response object in Error when non 200 HTTP status is received

* Remove HttpError from export
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
* Surface fetch Response object in Error when non 200 HTTP status is received

* Remove HttpError from export
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 this pull request may close these issues.

Surface status code in error when FileLoader gets a non-200 response
3 participants