github.com/fastly/cli@v1.7.2-0.20240304164155-9d0f1d77c3bf/pkg/errors/process.go (about) 1 package errors 2 3 import ( 4 "errors" 5 "io" 6 7 "github.com/fatih/color" 8 9 "github.com/fastly/cli/pkg/text" 10 ) 11 12 // Process persists the error log to disk and deduces the error type. 13 func Process(err error, args []string, out io.Writer) (skipExit bool) { 14 text.Break(out) 15 16 // NOTE: We persist any error log entries to disk before attempting to handle 17 // a possible error response from app.Run as there could be errors recorded 18 // during the execution flow but were otherwise handled without bubbling an 19 // error back the call stack, and so if the user still experiences something 20 // unexpected we will have a record of any errors that happened along the way. 21 logErr := Log.Persist(LogPath, args[1:]) 22 if logErr != nil { 23 Deduce(logErr).Print(color.Error) 24 } 25 26 // IMPORTANT: Deduce/Print needs to happen before checking for Skip. 27 // This is so the help output can be printed. 28 Deduce(err).Print(color.Error) 29 30 exitError := SkipExitError{} 31 if errors.As(err, &exitError) { 32 return exitError.Skip 33 } 34 return false 35 }