MCPcopy Create free account
hub / github.com/conforma/cli / appstudioErrorHandler

Function appstudioErrorHandler

cmd/test/appstudio.go:59–78  ·  view source on GitHub ↗

Special error handling for appstudio format only

(noFail bool, prefix string, err error)

Source from the content-addressed store, hash-verified

57
58// Special error handling for appstudio format only
59func appstudioErrorHandler(noFail bool, prefix string, err error) error {
60 // Output some json to stdout
61 applicationsnapshot.OutputAppstudioReport(applicationsnapshot.AppstudioReportForError(prefix, err))
62
63 // Beware we're effectively changing the meaning of the --no-fail flag here.
64 // Rather than being only about policy failures any more, we're extending
65 // it to also mean don't return a non-zero exit code for an error handled
66 // by this function.
67 if noFail {
68 // Still put the real error in stderr so there is some chance
69 // users can figure out what caused the problem
70 fmt.Fprintf(os.Stderr, "Error: %s: %s\n", prefix, err.Error())
71
72 // So the exit code is zero
73 return nil
74 } else {
75 // "Normal" behavior, return the formatted error
76 return fmt.Errorf("%s: %w", prefix, err)
77 }
78}

Callers 1

NewTestCommandFunction · 0.85

Calls 4

OutputAppstudioReportFunction · 0.92
AppstudioReportForErrorFunction · 0.92
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected