Skip to content

Commit 03b21a4

Browse files
committed
Always log stack traces for Error objects
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.
1 parent 5eb5d9b commit 03b21a4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

build_runner/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 2.4.7-wip
22

3+
- Print stack traces for `Error` subtype exceptions in non-verbose mode.
34
- Fix broken link in README.md.
45
- Bump the min sdk to 3.0.0.
56

build_runner/lib/src/logging/std_io_logging.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ StringBuffer colorLog(LogRecord record, {required bool verbose}) {
3333
lines.add(record.error!);
3434
}
3535

36-
if (record.stackTrace != null && verbose) {
36+
if (record.stackTrace != null && (verbose || record.error is Error)) {
3737
var trace = Trace.from(record.stackTrace!);
3838
const buildSystem = {'build_runner', 'build_runner_core', 'build'};
3939
if (trace.frames.isNotEmpty &&

0 commit comments

Comments
 (0)