Example #1
0
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)
}
Example #2
0
func setErrorFilePath(path string) errors.ErrorOption {
	return errors.SetData(filePathErrorKey, path)
}
Example #3
0
func setErrorLineNumber(lnr int) errors.ErrorOption {
	return errors.SetData(lineNumberErrorKey, lnr)
}
Example #4
0
// 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)
}
Example #5
0
// 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)
}
Example #6
0
// 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)
}
Example #7
0
/*
	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)
}