File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 99 "syscall"
1010
1111 "github.com/outblocks/outblocks-cli/cmd"
12+ "github.com/outblocks/outblocks-cli/pkg/actions"
1213 "google.golang.org/grpc/grpclog"
1314)
1415
@@ -43,10 +44,18 @@ func main() {
4344 err := exec .Execute (ctx )
4445
4546 if err != nil {
47+ if e , ok := err .(* actions.ErrExit ); ok {
48+ if e .Message != "" {
49+ exec .Log ().Errorln (e .Message )
50+ }
51+
52+ os .Exit (e .StatusCode ) //nolint
53+ }
54+
4655 if ctx .Err () != context .Canceled {
4756 exec .Log ().Errorln ("Error occurred:" , err )
4857 }
4958
50- os .Exit (1 ) //nolint: gocritic
59+ os .Exit (1 )
5160 }
5261}
Original file line number Diff line number Diff line change @@ -72,6 +72,15 @@ const (
7272 healthcheckTimeout = 3 * time .Second
7373)
7474
75+ type ErrExit struct {
76+ StatusCode int
77+ Message string
78+ }
79+
80+ func (e * ErrExit ) Error () string {
81+ return fmt .Sprintf ("exit code %d" , e .StatusCode )
82+ }
83+
7584func NewRun (log logger.Logger , cfg * config.Project , opts * RunOptions ) * Run {
7685 return & Run {
7786 log : log ,
@@ -751,7 +760,14 @@ func (d *Run) runSelfAsSudo() error {
751760 cmd .Stderr = os .Stderr
752761 cmd .Stdout = os .Stdout
753762
754- return cmd .Run ()
763+ err := cmd .Run ()
764+ if e , ok := err .(* exec.ExitError ); ok {
765+ return & ErrExit {
766+ StatusCode : e .ProcessState .ExitCode (),
767+ }
768+ }
769+
770+ return err
755771}
756772
757773func (d * Run ) Run (ctx context.Context ) error {
You can’t perform that action at this time.
0 commit comments