Merge "Add a default error code when updater script aborts" am: 89394632b1
am: 18bb9a4f26

Change-Id: I0614c33388d68a45d443de8058c2ee36e896c583
diff --git a/error_code.h b/error_code.h
index cde4ee6..0e79c87 100644
--- a/error_code.h
+++ b/error_code.h
@@ -24,6 +24,7 @@
   kZipOpenFailure,
   kBootreasonInBlacklist,
   kPackageCompatibilityFailure,
+  kScriptExecutionFailure,
 };
 
 enum CauseCode {
diff --git a/updater/updater.cpp b/updater/updater.cpp
index 749c86a..1be8b60 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -193,13 +193,15 @@
       }
     }
 
-    if (state.error_code != kNoError) {
-      fprintf(cmd_pipe, "log error: %d\n", state.error_code);
-      // Cause code should provide additional information about the abort;
-      // report only when an error exists.
-      if (state.cause_code != kNoCause) {
-        fprintf(cmd_pipe, "log cause: %d\n", state.cause_code);
-      }
+    // Installation has been aborted. Set the error code to kScriptExecutionFailure unless
+    // a more specific code has been set in errmsg.
+    if (state.error_code == kNoError) {
+      state.error_code = kScriptExecutionFailure;
+    }
+    fprintf(cmd_pipe, "log error: %d\n", state.error_code);
+    // Cause code should provide additional information about the abort.
+    if (state.cause_code != kNoCause) {
+      fprintf(cmd_pipe, "log cause: %d\n", state.cause_code);
     }
 
     if (updater_info.package_zip) {