From e334a0c20bfd18f7b1ef118b21565384af5cb2c5 Mon Sep 17 00:00:00 2001 From: Sourabh Mehta <73165318+soumeh01@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:19:28 +0200 Subject: [PATCH] Error message cleanup and Return same exit code as of orchestrated exe (#234) The change addresses 2 issues: - The error message `error generating build files` by cbuild is redundant. `cbuild `should return the same error which are reported by csolution covert step. - `cbuild `should return the same exit code provided by the orchestrated utlities. --- cmd/cbuild/main.go | 9 ++++++++- pkg/builder/csolution/builder.go | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/cbuild/main.go b/cmd/cbuild/main.go index 04428bb..e85cade 100644 --- a/cmd/cbuild/main.go +++ b/cmd/cbuild/main.go @@ -9,6 +9,7 @@ package main import ( "fmt" "os" + "os/exec" "github.com/Open-CMSIS-Pack/cbuild/v2/cmd/cbuild/commands" log "github.com/sirupsen/logrus" @@ -25,7 +26,13 @@ func main() { err := cmd.Execute() if err != nil { log.Error(err) - os.Exit(-1) + if exitError, ok := err.(*exec.ExitError); ok { + os.Exit(exitError.ExitCode()) + } else { + os.Exit(1) + } + } else { + os.Exit(0) } } diff --git a/pkg/builder/csolution/builder.go b/pkg/builder/csolution/builder.go index 2d4aedf..2795971 100644 --- a/pkg/builder/csolution/builder.go +++ b/pkg/builder/csolution/builder.go @@ -612,7 +612,6 @@ func (b CSolutionBuilder) Build() (err error) { // STEP 2: Generate build file(s) if err = b.generateBuildFiles(); err != nil { - log.Error("error generating build files") return err }