Skip to content

Commit

Permalink
Always log stack traces for Error objects (#3586)
Browse files Browse the repository at this point in the history
Closes #3585

The default logging omits stack traces by default and prints them only
in verbose mode. This is intended to allow builder implementations to
cease execution and log a user friendly message by throwing a single
`Exception` with a custom `toString()`. When a builder or utility
library has an implementation bug leading to an `Error` the stack trace
is much more likely to be useful information for debugging, and worth
including by default.
  • Loading branch information
natebosch committed Dec 16, 2023
1 parent 80b6526 commit ca7f881
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions build_runner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2.4.8-wip

- Update README.md to point to the FAQ and other docs.
- Print stack traces for `Error` subtype exceptions in non-verbose mode.

## 2.4.7

Expand Down
2 changes: 1 addition & 1 deletion build_runner/lib/src/logging/std_io_logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ StringBuffer colorLog(LogRecord record, {required bool verbose}) {
lines.add(record.error!);
}

if (record.stackTrace != null && verbose) {
if (record.stackTrace != null && (verbose || record.error is Error)) {
var trace = Trace.from(record.stackTrace!);
const buildSystem = {'build_runner', 'build_runner_core', 'build'};
if (trace.frames.isNotEmpty &&
Expand Down

0 comments on commit ca7f881

Please sign in to comment.