3

I'd like to be able to temporarily disable this behavior for "expected" exceptions in Chrome, for development purposes. For example, I have unit tests that create implementations of objects that intentionally throw exceptions; when running them, I'd like to not pause on "known" exceptions but pause on unexpected exceptions (for example, if there are bugs in the tests themselves).

Is there an easy way to do this? Blackboxing the scripts isn't really an option, as I want to know about unexpected exceptions (and it apparently doesn't work anyway; see Chrome dev tools pauses on exceptions in blackboxed script). Pausing only on uncaught exceptions isn't really an option, as the unit test driver catches all of them eventually, so it would never pause.

Is there either a way to toggle the option using JavaScript, or a fancier way to do it if I'm willing to write a browser extension (which I've done, but I'm not a whiz), or another technique of which I'm not aware?

Community
  • 1
  • 1
David P. Caldwell
  • 2,691
  • 16
  • 26

1 Answers1

0

No, there is no way to trigger that checkbox via javascript.

Generally, using exceptions to control the program flow is a bad practice. (e.g., see why not use exceptions as regular flow of control?)

If you absolutely need a constructor which sometimes doesn't construct, use Factory Methods, which might return nulls/errors.

Community
  • 1
  • 1
Andrey Lushnikov
  • 2,685
  • 2
  • 20
  • 19
  • Thanks. Yeah, I'm convinced that exceptions are the correct usage in this case -- `throw new TypeError(...)` when the wrong thing is passed to an API, etc. And I want to write tests that verify that `TypeError` is thrown when it should be. So I probably don't have a choice. – David P. Caldwell Feb 29 '16 at 00:05