CheckFatal prints an error and exits with error code 1 if err is non-nil
(location string, err error)
| 106 | |
| 107 | // CheckFatal prints an error and exits with error code 1 if err is non-nil |
| 108 | func CheckFatal(location string, err error) { |
| 109 | if err != nil { |
| 110 | logger := level.Error(Logger) |
| 111 | if location != "" { |
| 112 | logger = log.With(logger, "msg", "error "+location) |
| 113 | } |
| 114 | // %+v gets the stack trace from errors using github.com/pkg/errors |
| 115 | logger.Log("err", fmt.Sprintf("%+v", err)) |
| 116 | os.Exit(1) |
| 117 | } |
| 118 | } |