@@ -73,7 +73,6 @@ Tarballs can also be specified by simply providing the path to the .tar, .tar.gz
7373}
7474
7575func outputResults (resultMap map [string ]util.Result ) {
76-
7776 // Outputs diff/analysis results in alphabetical order by analyzer name
7877 sortedTypes := []string {}
7978 for analyzerType := range resultMap {
@@ -84,7 +83,7 @@ func outputResults(resultMap map[string]util.Result) {
8483 // Get the writer
8584 writer , err := getWriter (outputFile )
8685 if err != nil {
87- logrus . Error (err )
86+ errors . Wrap (err , "getting writer for output file" )
8887 }
8988
9089 results := make ([]interface {}, len (resultMap ))
@@ -100,7 +99,6 @@ func outputResults(resultMap map[string]util.Result) {
10099 }
101100 }
102101 if json {
103-
104102 err := util .JSONify (writer , results )
105103 if err != nil {
106104 logrus .Error (err )
@@ -176,20 +174,14 @@ func getCacheDir(imageName string) (string, error) {
176174func getWriter (outputFile string ) (io.Writer , error ) {
177175 var err error
178176 var outWriter io.Writer
179-
180177 // If the user specifies an output file, ensure exists
181178 if outputFile != "" {
182-
183179 // Don't overwrite a file that exists, unless given --force
184- if _ , err := os .Stat (outputFile ); ! os .IsNotExist (err ) {
185- if ! forceWrite {
186- logrus .Error ("file exist, will not overwrite." )
187- }
180+ if _ , err := os .Stat (outputFile ); ! os .IsNotExist (err ) && ! forceWrite {
181+ errors .Wrap (err , "file exist, will not overwrite." )
188182 }
189-
190183 // Otherwise, output file is an io.writer
191184 outWriter , err = os .Create (outputFile )
192-
193185 }
194186 // If still doesn't exist, return stdout as the io.Writer
195187 if outputFile == "" {
0 commit comments