Skip to content

Commit a0cb07d

Browse files
authored
Add more context about dartfmt failures (#132)
* Add more context about dartfmt failures Closes #130. I validated internally this produces a nicer error message, such as: ``` [SEVERE]: Error formatting the generated source code for <REDACTED>|lib/focus_trap.dart which was output to lib/focus_trap.template.dart. This may indicate an issue in the generated code or in the formatter. Please check the generated code and file an issue on source_gen if appropriate. Could not format because the source could not be parsed: ``` * Update builder.dart
1 parent 09036ae commit a0cb07d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/src/builder.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ class GeneratorBuilder extends Builder {
7878
genPartContent = formatter.format(genPartContent);
7979
} catch (e, stack) {
8080
buildStep.logger.severe(
81-
"""Error formatting the generated source code.
82-
This may indicate an issue in the generated code or in the formatter.
83-
Please check the generated code and file an issue on source_gen
84-
if approppriate.""",
81+
'''Error formatting generated source code for ${library.identifier}
82+
which was output to ${_generatedFile(buildStep.inputId).path}.\n
83+
This may indicate an issue in the generated code or in the formatter.\n
84+
Please check the generated code and file an issue on source_gen if appropriate.''',
8585
e,
8686
stack);
8787
}

0 commit comments

Comments
 (0)