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

Implement better error message for the v4 #1290

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

peaBerberian
Copy link
Collaborator

Until now, the RxPlayer's errors set the Error's name property inside its message property.

When logged in the console, such errors are automatically formatted by the browser which generally choose to re-use the name to produce a meaningful error string.
This lead to a repeat like:
EncryptedMediaError: EncryptedMediaError (INCOMPATIBLE_KEYSYSTEMS) Some description message

This was unnecessary and kind of ugly but we were afraid some apps were for whatever reasons exploiting the message string and thus did not change it in the v3.

For the v4 we choose a more consize message: The code, followed by a colon, followed by a description of what happened. As such, the previous example would look like in a JS console when logged:
EncryptedMediaError: INCOMPATIBLE_KEYSYSTEMS: Some description message

If applications want to detect the error's name/type they can respectively rely on the more appropriate name or type property (basically the name is the PascalCased name here to have an idiomatic JS error, type is the RxPlayer's documented UPPER_SNAKE_CASE version of the name).

Note that the error's message is still not part of the API and applications should still expect that it could theoretically change its format at any time, even if we're generally (too?) careful with that sort of things.

@peaBerberian peaBerberian added this to the 4.0.0-beta.3 milestone Sep 26, 2023
@peaBerberian peaBerberian force-pushed the misc/better-v4-error-message branch from dd13009 to 2d72320 Compare September 26, 2023 13:28
@peaBerberian peaBerberian force-pushed the misc/better-v4-error-message branch 3 times, most recently from cfaf0fd to 32d690e Compare September 26, 2023 16:24
@peaBerberian peaBerberian force-pushed the next-v4 branch 2 times, most recently from b5e1161 to 7c01cf7 Compare September 27, 2023 08:30
Until now, the RxPlayer's errors set the Error's `name` property inside
its `message` property.

When logged in the console, such errors are automatically formatted by
the browser which generally choose to re-use the `name` to produce a
meaningful error string.
This lead to a repeat like:
`EncryptedMediaError: EncryptedMediaError (INCOMPATIBLE_KEYSYSTEMS) Some description message`

This was unnecessary and kind of ugly but we were afraid some apps were
for whatever reasons exploiting the `message` string and thus did not change
it in the v3.

For the `v4` we choose a more consize message: The code, followed by a
colon, followed by a description of what happened.
As such, the previous example would look like in a JS console when
logged:
`EncryptedMediaError: INCOMPATIBLE_KEYSYSTEMS: Some description message`

If applications want to detect the error's name/type they can
respectively rely on the more appropriate `name` or `type` property
(basically the `name` is the PascalCased name here to have an idiomatic
JS error, `type` is the RxPlayer's documented UPPER_SNAKE_CASE version
of the name).

Note that the error's message is still not part of the API and
applications should still expect that it could theoretically change its
format at any time, even if we're generally (too?) careful with that
sort of things.
@peaBerberian peaBerberian force-pushed the misc/better-v4-error-message branch from 32d690e to 8390ead Compare September 27, 2023 08:53
@peaBerberian peaBerberian merged commit 45516d8 into next-v4 Sep 27, 2023
3 checks passed
peaBerberian added a commit that referenced this pull request Sep 27, 2023
Implement better error message for the v4
peaBerberian added a commit that referenced this pull request Sep 29, 2023
Implement better error message for the v4
peaBerberian added a commit that referenced this pull request Oct 13, 2023
Implement better error message for the v4
peaBerberian added a commit that referenced this pull request Oct 13, 2023
Implement better error message for the v4
peaBerberian added a commit that referenced this pull request Oct 13, 2023
Implement better error message for the v4
peaBerberian added a commit that referenced this pull request Oct 19, 2023
Implement better error message for the v4
peaBerberian added a commit that referenced this pull request Oct 26, 2023
Implement better error message for the v4
@peaBerberian peaBerberian deleted the misc/better-v4-error-message branch February 7, 2024 16:31
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.

1 participant