コード例 #1
0
ファイル: errors.go プロジェクト: kkroening/repeatr
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
ファイル: parse.go プロジェクト: uwedeportivo/romba
func setErrorFilePath(path string) errors.ErrorOption {
	return errors.SetData(filePathErrorKey, path)
}
コード例 #3
0
ファイル: parse.go プロジェクト: uwedeportivo/romba
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
ファイル: errors.go プロジェクト: kkroening/repeatr
/*
	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)
}