示例#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)
}
示例#2
0
func setErrorFilePath(path string) errors.ErrorOption {
	return errors.SetData(filePathErrorKey, path)
}
示例#3
0
func setErrorLineNumber(lnr int) errors.ErrorOption {
	return errors.SetData(lineNumberErrorKey, lnr)
}
示例#4
0
文件: http.go 项目: leobcn/errors
// 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)
}
示例#5
0
文件: http.go 项目: leobcn/errors
// 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)
}
示例#6
0
文件: http.go 项目: leobcn/errors
// 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)
}
示例#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)
}