Commit 70e20153 authored by Devon Carew's avatar Devon Carew

use stack_trace to create more readable exception traces

parent 4c99319f
...@@ -7,6 +7,7 @@ import 'dart:io'; ...@@ -7,6 +7,7 @@ import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:stack_trace/stack_trace.dart';
import 'src/commands/build.dart'; import 'src/commands/build.dart';
import 'src/commands/cache.dart'; import 'src/commands/cache.dart';
...@@ -53,22 +54,22 @@ Future main(List<String> args) async { ...@@ -53,22 +54,22 @@ Future main(List<String> args) async {
..addCommand(new StopCommand()) ..addCommand(new StopCommand())
..addCommand(new TraceCommand()); ..addCommand(new TraceCommand());
try { return Chain.capture(() async {
dynamic result = await runner.run(args); dynamic result = await runner.run(args);
if (result is int) if (result is int)
exit(result); exit(result);
} on UsageException catch (e) { }, onError: (error, Chain chain) {
stderr.writeln(e); if (error is UsageException) {
// Args error exit code. stderr.writeln(error);
exit(64); // Argument error exit code.
} catch (e, stack) { exit(64);
if (e is ProcessExit) { } else if (error is ProcessExit) {
// We've caught an exit code. // We've caught an exit code.
exit(e.exitCode); exit(error.exitCode);
} else {
stderr.writeln(error);
Logger.root.log(Level.SEVERE, '\nException:', null, chain.terse.toTrace());
exit(1);
} }
});
stderr.writeln(e);
Logger.root.log(Level.SEVERE, '\nException:', null, stack);
exit(1);
}
} }
...@@ -17,6 +17,7 @@ dependencies: ...@@ -17,6 +17,7 @@ dependencies:
shelf_route: ^0.13.4 shelf_route: ^0.13.4
shelf_static: ^0.2.3 shelf_static: ^0.2.3
shelf: ^0.6.2 shelf: ^0.6.2
stack_trace: ^1.4.0
test: ^0.12.5 test: ^0.12.5
yaml: ^2.1.3 yaml: ^2.1.3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment