Skip to content

Adds onError with just the ability to change the fall back value, cus…#75

Open
dwjohnston wants to merge 1 commit into
astoilkov:mainfrom
dwjohnston:onError-1
Open

Adds onError with just the ability to change the fall back value, cus…#75
dwjohnston wants to merge 1 commit into
astoilkov:mainfrom
dwjohnston:onError-1

Conversation

@dwjohnston

@dwjohnston dwjohnston commented Nov 18, 2024

Copy link
Copy Markdown

Adds a onError option, that allows the user to:

  1. Determine what the fallback value should be if a parsing error occurs.
  2. Allow any other logging functionality etc,.

Comment thread test/browser.test.tsx
// I really want to be able to write a test like this!
// But it's not working? JSDOM has implemented the storageEvent thought:
// https://github.com/jsdom/jsdom/pull/2076
test.skip("sanity test", async () => {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

nb. 👈

Comment thread test/browser.test.tsx
@@ -25,7 +27,13 @@ beforeEach(() => {
// (`Component`). To locate the bad setState() call inside `Component`, follow the stack trace
// as described in https://reactjs.org/link/setstate-in-render"
vi.spyOn(console, 'error').mockImplementation((format: string, ...args: any[]) => {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I do like this pattern.

What I've done in the past is maintained a list of allowed errors, and a second list of errors that should be printed to the console.

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.

2 participants