From 8c8f3d6d2acb6a7174e4e864fbd9d5ed873b0565 Mon Sep 17 00:00:00 2001 From: "leedongmyung[desktop]" Date: Sat, 18 Nov 2023 19:51:55 +0900 Subject: [PATCH] exception handling update --- lib/oto/application.dart | 2 +- lib/oto/build/build_dart.dart | 2 +- lib/oto/command.dart | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/oto/application.dart b/lib/oto/application.dart index ad9afa4..22d00c3 100644 --- a/lib/oto/application.dart +++ b/lib/oto/application.dart @@ -58,7 +58,7 @@ class Application { await CLI.printString(e.toString(), color: Color.redStrong); await CLI.printString(stacktace.toString(), color: Color.yellowStrong); await printBuildStep('Build Failed', Color.redStrong); - return; + exit(10); } await printBuildStep('Build Successfully Complete', Color.cyan); diff --git a/lib/oto/build/build_dart.dart b/lib/oto/build/build_dart.dart index 28984fa..2bb9de4 100644 --- a/lib/oto/build/build_dart.dart +++ b/lib/oto/build/build_dart.dart @@ -38,6 +38,6 @@ class BuildDart extends Command { workspace: workspace, enableStderr: false); return await complete(await process.process.exitCode, command, - errorMessage: process.stderr.toString(), passCode: [0, 64]); + errorMessage: process.stderr.toString()); } } diff --git a/lib/oto/command.dart b/lib/oto/command.dart index 2fb5961..52ce997 100644 --- a/lib/oto/command.dart +++ b/lib/oto/command.dart @@ -129,7 +129,8 @@ abstract class Command { if (passCode.contains(exitCode)) { return simpleFuture; } else { - var data = ExcpetionData(); + print('Exit Code: $exitCode'); + var data = ExceptionData(); data.phase = command.name; data.message = errorMessage; throw Exception(data); @@ -148,7 +149,14 @@ class SimpleCommand extends Command { } } -class ExcpetionData { +class ExceptionData { String? phase; String? message; + + @override + String toString() { + var str = ' [$phase]\n\n'; + str += message ??= ''; + return str; + } }