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

Why TypeError instead of DOMException DataError for decompression failure? #51

Open
saschanaz opened this issue Mar 22, 2023 · 3 comments

Comments

@saschanaz
Copy link
Member

saschanaz commented Mar 22, 2023

https://wicg.github.io/compression/#decompress-flush-and-enqueue

  1. If the end of the compressed input has not been reached, then throw a TypeError.

Not that it matters too much, but not sure TypeError makes much sense there.

@ricea
Copy link
Collaborator

ricea commented Mar 23, 2023

I have a preference for simple exceptions, but I don't have a good justification for it.

I think the compatibility risk for changing this would probably be minimal, but I don't have a way of measuring it.

@domenic Can I ask you for an opinion?

@domenic
Copy link
Member

domenic commented Mar 23, 2023

I think the relevant question is whether there are use cases for discriminating the error types coming out of the stream. If so, using separate exception types is worthwhile. If not, sticking with the generic, default TypeError makes sense.

@ricea
Copy link
Collaborator

ricea commented Mar 24, 2023

For someone trying to use DecompressionStream for the first time, it might be useful to distinguish between TypeError meaning "you gave me something that wasn't a BufferSource" and DataError meaning "the input was not a valid compressed stream".

On the other hand, TextDecoderStream uses TypeError for bad input, and maybe consistency is more important here.

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

No branches or pull requests

3 participants