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

🪲 Remove a source of client exceptions #5812

Merged
merged 3 commits into from
Sep 26, 2024
Merged

🪲 Remove a source of client exceptions #5812

merged 3 commits into from
Sep 26, 2024

Conversation

rix0rrr
Copy link
Collaborator

@rix0rrr rix0rrr commented Sep 25, 2024

A lot of client exceptions were originating from the embedded editor, trying to call removeAttribute() on an object that happened to be null.

The reason was an assertion that the result of getElementById() would never be null, where in fact, it was.

Replace with a null coalescing function call ?.removeAttribute() so that the function call falls to the floor if the element doesn't exist.

How to test

Visit http://localhost:8080/embedded/1/?lang=nl&run=true&readOnly=false&fullWidth=false&program=IyBTY2hyaWpmIGpvdXcgY29kZSBoaWVy%22 and run any program. Observe that no exceptions get logged to the JavaScript console.

(cc @jpelay, I spied you here 😛 this is why ! is dangerous, even you think this can never happen there's always a case you didn't think of -- better to program defensively or fail real hard with an explicit error message)

A lot of client exceptions were originating from the embedded
editor, trying to call `removeAttribute()` on an object that
happened to be `null`.

The reason was an assertion that the result of `getElementById()`
would never be `null`, where in fact, it was.

Replace with a null coalescing function call `?.removeAttribute()`
so that the function call falls to the floor if the element doesn't
exist.

**How to test**

Visit http://localhost:8080/embedded/1/?lang=nl&run=true&readOnly=false&fullWidth=false&program=IyBTY2hyaWpmIGpvdXcgY29kZSBoaWVy%22
and run any program. Observe that no exceptions get logged to the
JavaScript console.
@rix0rrr rix0rrr requested a review from jpelay September 25, 2024 18:46
Copy link
Member

@jpelay jpelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cc @jpelay, I spied you #5673 😛 this is why ! is dangerous, even you think this can never happen there's always a case you didn't think of -- better to program defensively or fail real hard with an explicit error message)

Dang it! Sorry, you're right, should've the ? instead.

Copy link
Contributor

mergify bot commented Sep 26, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 3e184a4 into main Sep 26, 2024
11 checks passed
@mergify mergify bot deleted the no-exceptions branch September 26, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants