Index: pkg/scheduled_test/lib/src/schedule_error.dart |
diff --git a/pkg/scheduled_test/lib/src/schedule_error.dart b/pkg/scheduled_test/lib/src/schedule_error.dart |
index 3df208a01d353dc8821feb4976f70087f6c7bddc..07dc3bfd6f0d9fc6bc2724b9c7caf9a0282c6823 100644 |
--- a/pkg/scheduled_test/lib/src/schedule_error.dart |
+++ b/pkg/scheduled_test/lib/src/schedule_error.dart |
@@ -50,12 +50,8 @@ class ScheduleError extends AsyncError { |
error = error.error; |
} |
- if (stackTrace == null) { |
- try { |
- throw ''; |
- } catch (_, thrownStackTrace) { |
- stackTrace = thrownStackTrace; |
- } |
+ if (schedule.captureStackTraces && stackTrace == null) { |
+ stackTrace = new Trace.current(); |
} |
return new ScheduleError(schedule, error, stackTrace, cause); |
@@ -88,9 +84,11 @@ class ScheduleError extends AsyncError { |
result.write('ScheduleError: "$errorString"\n'); |
} |
- result.write('Stack trace:\n'); |
- result.write(prefixLines(terseTraceString(stackTrace))); |
- result.write("\n\n"); |
+ if (stackTrace != null) { |
+ result.write('Stack trace:\n'); |
+ result.write(prefixLines(terseTraceString(stackTrace))); |
+ result.write("\n\n"); |
+ } |
if (task != null) { |
result.write('Error detected during task in queue "$queue":\n'); |