create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

react-error-overlay throwing errors caught through try catch block

Open sukhminderx opened this issue 8 years ago • 4 comments

Hi

I am using react version 16.x.x. I have added a try catch block. When my try throws an error, the catch block executes. But after that react-error-overlay throws the error that was caught and breaks the app.

Sample code: try{ initCommon(); fin.desktop.main(function() { console.log('fin available'); }); }catch(err){ console.log('fin not available'); }

Here I get the message 'fin not available' in console. But after that I get this error:

error 'fin' is not defined no-undef

Please let me know why react-error-overlay is causing this.

sukhminderx avatar Jan 17 '18 10:01 sukhminderx

Can you provide a complete example? It’s not very clear to me what you’re asking. Screenshots would also help.

gaearon avatar Jan 17 '18 11:01 gaearon

Hi Gaearon,

Please find the screenshot: image

Its a try catch block. Ideally, the exception should be thrown to catch and the app should work. But after the catch gets the exception, the error forces the app to halt.

image

sukhminderx avatar Jan 17 '18 15:01 sukhminderx

Attached: console showing the the catch block executes:

image

sukhminderx avatar Jan 17 '18 15:01 sukhminderx

Okay, so the problem here is not the exception, but a strict lint check.

We ask that if you must intend to use a global variable, you should prefix it with window. to make the intent clear. This helps discover typos.

If you replace qwerty with window.qwerty your example will compile.

gaearon avatar Jan 17 '18 15:01 gaearon