dart-lang / webdev

A CLI for Dart web development.
https://pub.dev/packages/webdev
213 stars 71 forks source link

Can add breakpoints to a project using macros #2403

Closed elliette closed 3 months ago

elliette commented 3 months ago

Fixes https://github.com/dart-lang/webdev/issues/2396

This PR does not add support for debugging macros in DWDS, it simply fixes an error where trying to set a breakpoint in a project using macros would fail.

The first time a user sets a breakpoint in their app, DWDS creates (and memoizes) locations for the entire module. However, if it encounters a URI for a location in a format it doesn't understand, it throws an error. This error was not being caught by DWDS, which meant that setting a breakpoint anywhere would fail.

This PR catches that error and logs it, and skips adding a location if the format is unrecognized:

Error adding location for dart-macro+file:/Users/elliottbrooks/dev/test_apps/macros_example/lib/main.dart: FormatException: Unsupported URI form: dart-macro+file:/Users/elliottbrooks/dev/test_apps/macros_example/lib/main.dart