exception handling update

This commit is contained in:
leedongmyung[desktop] 2023-11-18 19:51:55 +09:00
parent b326a7d3a4
commit 8c8f3d6d2a
3 changed files with 12 additions and 4 deletions

View file

@ -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);

View file

@ -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());
}
}

View file

@ -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;
}
}