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

DetailedError type definitions are missing possible nulls #550

Closed
nh2 opened this issue Feb 1, 2023 · 2 comments · Fixed by #582
Closed

DetailedError type definitions are missing possible nulls #550

nh2 opened this issue Feb 1, 2023 · 2 comments · Fixed by #582
Labels

Comments

@nh2
Copy link
Contributor

nh2 commented Feb 1, 2023

The types say all fields in DetailedError are guaranteed to be peresent:

export class DetailedError extends Error {
originalRequest: HttpRequest;
originalResponse: HttpResponse;
causingError: Error;
}

But they are null sometimes. This caused a runtime crash in my app.

I think this would be a great idea, as humans just aren't good at tracking what can be null and what cannot:

Cause

class DetailedError extends Error {
constructor (message, causingErr = null, req = null, res = null) {

  • causingError can be null:
    throw new DetailedError('tus: unexpected response while terminating upload', null, req, res)
  • originalResponse can be null:

    tus-js-client/lib/upload.js

    Lines 126 to 128 in 4ff243c

    if (!(err instanceof DetailedError)) {
    err = new DetailedError('tus: failed to terminate upload', err, req, null)
    }
@nh2 nh2 added the bug label Feb 1, 2023
@Acconut
Copy link
Member

Acconut commented Feb 6, 2023

You are correct, thank you for reporting! Would you be able to submit a PR to fix the current type definitions? Getting the automatically generated is a nice improvement but will probably take some time to achieve.

@nh2
Copy link
Contributor Author

nh2 commented Apr 14, 2023

PR in #582.

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

Successfully merging a pull request may close this issue.

2 participants