dart-archive / dev_compiler

DEPRECATED - Moved to main SDK
https://github.com/dart-lang/sdk/tree/master/pkg/dev_compiler
Other
133 stars 27 forks source link

Trap on common errors #509

Open vsmenon opened 8 years ago

vsmenon commented 8 years ago

The debugging experience, especially for large apps, is much better if we automatically trap on certain errors.

Catch on all exceptions doesn't seem to work well with Angular2 - they explicitly throw to record stack traces. One alternative is to make that work.

Another is to trap on explicit Dart errors (NullValue, NSM, Cast) - but this misses cases where we rely on the JS implementation to throw TypeErrors (null method or field).

jmesserly commented 8 years ago

by "trap" do you mean "debugger;" statement? http://www.ecma-international.org/ecma-262/6.0/#sec-debugger-statement

jacob314 commented 8 years ago

When https://bugs.chromium.org/p/chromium/issues/detail?id=589980&q=component%3APlatform%3EDevTools%20pause&sort=-stars&colspec=ID%20Owner%20Summary%20Modified%20Stars is fixed, chrome devtools will support this case via blackboxing and pause on all exceptions.

A right click to blackbox each script when you see it throw an error is all that is required.

Longer term there are two other options:

  1. Ask chrome devtools to support a pause on all exceptions with the ability to provide a filter on the exception object.
  2. Use the existing chrome functionality to track async stack traces instead of having dart code throw and catch to capture stack traces. Integrating with the existing chrome async stack trace functionality has the added benefit that inspection is supported on the async stack frames. This wouldn't solve all "applications catch and throw for spurious reasons" annoyances but would help a lot.