Skip to content

Conversation

@camdecoster
Copy link
Contributor

Description

Add logic to catch errors when mocks are loaded in plotly.js DevTools and log a message.

Closes #7637.

Changes

  • Add error handling logic

Testing

  • Be on master
  • Add an empty JSON file to the mocks folder:
    touch test/image/mocks/empty_file.json
  • Run npm start
  • Note that the process crashes
  • Switch to this branch
  • Run npm start
  • Note that the process doesn't crash and an error message is logged

@camdecoster camdecoster self-assigned this Nov 14, 2025
keywords: types.join(', ')
};
} catch {
console.log(`Couldn't parse ${file.name} as JSON. Excluding from mocks list.`);
Copy link
Contributor

Choose a reason for hiding this comment

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

@camdecoster Could we still surface the stack trace here, in case the code inside try fails in an unexpected way due to something other than the call to JSON.parse()?

Either that, or put only the JSON.parse() call inside the try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added more specific error handling.

Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

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

One comment but not a blocker, otherwise LGTM

@camdecoster camdecoster merged commit 59e986c into master Nov 17, 2025
5 of 6 checks passed
@camdecoster camdecoster deleted the cam/7637/catch-error-malformed-json branch November 17, 2025 16:08
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.

[BUG]: plotly.js DevTools crashes if malformed JSON file exists in mocks folder

3 participants