@@ -1056,11 +1056,29 @@ Executed at: {executed_at}"#,
10561056 }
10571057 } ;
10581058
1059- let fail = |message : & str | {
1059+ let fail = |message : & str , output : CommandOutput | -> ! {
10601060 if self . is_verbose ( ) {
10611061 println ! ( "{message}" ) ;
10621062 } else {
1063- println ! ( "Command has failed. Rerun with -v to see more details." ) ;
1063+ let ( stdout, stderr) = ( output. stdout_if_present ( ) , output. stderr_if_present ( ) ) ;
1064+ // If the command captures output, the user would not see any indication that
1065+ // it has failed. In this case, print a more verbose error, since to provide more
1066+ // context.
1067+ if stdout. is_some ( ) || stderr. is_some ( ) {
1068+ if let Some ( stdout) =
1069+ output. stdout_if_present ( ) . take_if ( |s| !s. trim ( ) . is_empty ( ) )
1070+ {
1071+ println ! ( "STDOUT:\n {stdout}\n " ) ;
1072+ }
1073+ if let Some ( stderr) =
1074+ output. stderr_if_present ( ) . take_if ( |s| !s. trim ( ) . is_empty ( ) )
1075+ {
1076+ println ! ( "STDERR:\n {stderr}\n " ) ;
1077+ }
1078+ println ! ( "Command {command:?} has failed. Rerun with -v to see more details." ) ;
1079+ } else {
1080+ println ! ( "Command has failed. Rerun with -v to see more details." ) ;
1081+ }
10641082 }
10651083 exit ! ( 1 ) ;
10661084 } ;
@@ -1069,14 +1087,14 @@ Executed at: {executed_at}"#,
10691087 match command. failure_behavior {
10701088 BehaviorOnFailure :: DelayFail => {
10711089 if self . fail_fast {
1072- fail ( & message) ;
1090+ fail ( & message, output ) ;
10731091 }
10741092
10751093 let mut failures = self . delayed_failures . borrow_mut ( ) ;
10761094 failures. push ( message) ;
10771095 }
10781096 BehaviorOnFailure :: Exit => {
1079- fail ( & message) ;
1097+ fail ( & message, output ) ;
10801098 }
10811099 BehaviorOnFailure :: Ignore => {
10821100 // If failures are allowed, either the error has been printed already
0 commit comments