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

Try...catch demo not logging finally if throwing #37694

Open
SimplySayHi opened this issue Jan 17, 2025 · 1 comment
Open

Try...catch demo not logging finally if throwing #37694

SimplySayHi opened this issue Jan 17, 2025 · 1 comment
Labels
to move If the issue doesn't belong in Content but elsewhere in the MDN org

Comments

@SimplySayHi
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

The demo if try...catch page is not completely working.
I changed the demo code like:

try {
  nonExistentFunction();
} catch (error) {
  console.error(error);
  // Expected output: ReferenceError: nonExistentFunction is not defined
  // (Note: the exact output may be browser-dependent)
  throw error
} finally {
  console.log("Finally")
}

Then clicked the button "Run".
Because of throw error in the catch block, the console.log in the finally block is not printed inside the box just below.

What did you expect to see?

I'd expect to see that the log "Finally" is printed in the box at bottom of the demo

Do you have any supporting links, references, or citations?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#try_it

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@SimplySayHi SimplySayHi added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 17, 2025
@github-actions github-actions bot added the Content:JS JavaScript docs label Jan 17, 2025
@Josh-Cena
Copy link
Member

This is a problem with our interactive example editor. If it catches an error, it never logs anything else. We just need to change this: https://github.com/mdn/bob/blob/main/editor/js/editable-js.ts#L89 from textContent = to textContent +=.

@Josh-Cena Josh-Cena added to move If the issue doesn't belong in Content but elsewhere in the MDN org and removed Content:JS JavaScript docs needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jan 17, 2025
@Josh-Cena Josh-Cena changed the title Try...catch demo not logging finally if added Try...catch demo not logging finally if throwing Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to move If the issue doesn't belong in Content but elsewhere in the MDN org
Projects
None yet
Development

No branches or pull requests

2 participants