func NewHashMismatchError(expectedHash, actualHash string) *errors.Error { return HashMismatchError.NewWith( fmt.Sprintf("expected hash %q, got %q", expectedHash, actualHash), errors.SetData(HashExpectedKey, expectedHash), errors.SetData(HashActualKey, actualHash), ).(*errors.Error) }
func setErrorFilePath(path string) errors.ErrorOption { return errors.SetData(filePathErrorKey, path) }
func setErrorLineNumber(lnr int) errors.ErrorOption { return errors.SetData(lineNumberErrorKey, lnr) }
// RestoreDefaultErrorBody returns an ErrorOption (for use in ErrorClass // creation or error instantiation) that restores the default error body shown // by GetErrorBody for some subhierarchy of errors. func RestoreDefaultErrorBody() errors.ErrorOption { return errors.SetData(errorBody, nil) }
// OverrideErrorBody returns an ErrorOption (for use in ErrorClass creation or // error instantiation) that controls the error body seen by GetErrorBody. func OverrideErrorBody(message string) errors.ErrorOption { return errors.SetData(errorBody, message) }
// SetStatusCode returns an ErrorOption (for use in ErrorClass creation or // error instantiation) that controls the error's HTTP status code func SetStatusCode(code int) errors.ErrorOption { return errors.SetData(statusCode, code) }
/* Use this to set a specific error code the process should exit with when producing a `cli.Error`. Example: `cli.Error.NewWith("something terrible!", SetExitCode(EXIT_BADARGS))` */ func SetExitCode(code ExitCode) errors.ErrorOption { return errors.SetData(ExitCodeKey, code) }