dev_compiler
dev_compiler copied to clipboard
Trap on common errors
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).
by "trap" do you mean "debugger;" statement? http://www.ecma-international.org/ecma-262/6.0/#sec-debugger-statement
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:
- Ask chrome devtools to support a pause on all exceptions with the ability to provide a filter on the exception object.
- 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.