| 1 | package utils |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | ) |
| 7 | |
| 8 | // Fail prints out the error struct if STEPDEBUG is true otherwise it just |
| 9 | // prints out the error message. Finally, it exits with an error code of 1. |
| 10 | func Fail(err error) { |
| 11 | if err != nil { |
| 12 | if os.Getenv("STEPDEBUG") == "1" { |
| 13 | fmt.Fprintf(os.Stderr, "%+v\n", err) |
| 14 | } else { |
| 15 | fmt.Fprintln(os.Stderr, err) |
| 16 | } |
| 17 | os.Exit(1) |
| 18 | } |
| 19 | } |