File tree Expand file tree Collapse file tree 5 files changed +48
-11
lines changed
workloads/cortex/client/cortex/binary Expand file tree Collapse file tree 5 files changed +48
-11
lines changed Original file line number Diff line number Diff line change @@ -120,16 +120,22 @@ var _deployCmd = &cobra.Command{
120120 exit .Error (err )
121121 }
122122 fmt .Println (string (bytes ))
123- return
124123 case flags .MixedOutputType :
125124 err := mixedPrint (deployResults )
126125 if err != nil {
127126 exit .Error (err )
128127 }
129- return
130128 case flags .PrettyOutputType :
131129 message := deployMessage (deployResults , env .Name )
132- print .BoldFirstBlock (message )
130+ if didAnyResultsError (deployResults ) {
131+ print .StderrBoldFirstBlock (message )
132+ } else {
133+ print .BoldFirstBlock (message )
134+ }
135+ }
136+
137+ if didAnyResultsError (deployResults ) {
138+ exit .Error (nil )
133139 }
134140 },
135141}
@@ -297,6 +303,15 @@ func didAllResultsError(results []schema.DeployResult) bool {
297303 return true
298304}
299305
306+ func didAnyResultsError (results []schema.DeployResult ) bool {
307+ for _ , result := range results {
308+ if result .Error != "" {
309+ return true
310+ }
311+ }
312+ return false
313+ }
314+
300315func getAPICommandsMessage (results []schema.DeployResult , envName string ) string {
301316 apiName := "<api_name>"
302317 if len (results ) == 1 {
Original file line number Diff line number Diff line change @@ -17,15 +17,14 @@ limitations under the License.
1717package errors
1818
1919import (
20- "os"
2120 "strings"
2221
2322 "github.com/aws/aws-sdk-go/aws/awserr"
2423 "github.com/cortexlabs/cortex/pkg/lib/print"
2524)
2625
2726func PrintError (err error , strs ... string ) {
28- os . Stderr . WriteString (ErrorStr (err , strs ... ) + " \n " )
27+ print . StderrPrintln (ErrorStr (err , strs ... ))
2928 // PrintStacktrace(err)
3029}
3130
Original file line number Diff line number Diff line change @@ -33,11 +33,11 @@ func Error(err error, wrapStrs ...string) {
3333 err = errors .Wrap (err , str )
3434 }
3535
36- if ! errors .IsNoTelemetry (err ) {
36+ if err != nil && ! errors .IsNoTelemetry (err ) {
3737 telemetry .Error (err )
3838 }
3939
40- if ! errors .IsNoPrint (err ) {
40+ if err != nil && ! errors .IsNoPrint (err ) {
4141 errors .PrintErrorForUser (err )
4242 }
4343
@@ -51,7 +51,7 @@ func Panic(err error, wrapStrs ...string) {
5151 err = errors .Wrap (err , str )
5252 }
5353
54- if ! errors .IsNoTelemetry (err ) {
54+ if err != nil && ! errors .IsNoTelemetry (err ) {
5555 telemetry .Error (err )
5656 }
5757
Original file line number Diff line number Diff line change @@ -45,14 +45,14 @@ func StderrBoldFirstLine(msg string) {
4545 msgParts := strings .Split (msg , "\n " )
4646
4747 if len (msgParts [0 ]) > _maxBoldLength {
48- os . Stderr . WriteString (msg + " \n " )
48+ StderrPrintln (msg )
4949 return
5050 }
5151
52- os . Stderr . WriteString (console .Bold (msgParts [0 ]) + " \n " )
52+ StderrPrintln (console .Bold (msgParts [0 ]))
5353
5454 if len (msgParts ) > 1 {
55- os . Stderr . WriteString (strings .Join (msgParts [1 :], "\n " ) + " \n " )
55+ StderrPrintln (strings .Join (msgParts [1 :], "\n " ))
5656 }
5757}
5858
@@ -71,7 +71,26 @@ func BoldFirstBlock(msg string) {
7171 }
7272}
7373
74+ func StderrBoldFirstBlock (msg string ) {
75+ msgParts := strings .Split (msg , "\n \n " )
76+
77+ if len (msgParts [0 ]) > _maxBoldLength {
78+ StderrPrintln (msg )
79+ return
80+ }
81+
82+ StderrPrintln (console .Bold (msgParts [0 ]))
83+
84+ if len (msgParts ) > 1 {
85+ StderrPrintln ("\n " + strings .Join (msgParts [1 :], "\n \n " ))
86+ }
87+ }
88+
7489func Dot () error {
7590 fmt .Print ("." )
7691 return nil
7792}
93+
94+ func StderrPrintln (str string ) {
95+ os .Stderr .WriteString (str + "\n " )
96+ }
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ def run_cli(
7777 result = "~"
7878 output = output [:- 1 ]
7979 if result_found :
80+ output = output [:- 1 ]
8081 if c == "\n " :
8182 result_found = False
8283 result = result [len (MIXED_CORTEX_MARKER ) : - len (MIXED_CORTEX_MARKER )]
@@ -96,6 +97,9 @@ def run_cli(
9697 return result
9798 return output
9899
100+ if result != "" :
101+ raise CortexBinaryException (result + "\n " + process .stderr .read ())
102+
99103 raise CortexBinaryException (process .stderr .read ())
100104
101105
You can’t perform that action at this time.
0 commit comments