Documentation
¶
Index ¶
- Constants
- func BaseFuncMap() template.FuncMap
- func BuildInfo() string
- func CheckTestError(t *testing.T, err error, want *Error) bool
- func InsertSliceElem[T any](slice []T, element T, index int) ([]T, error)
- type DeployEnv
- type Error
- type ErrorChain
- type HelpLink
- type MockStringHandler
- type MockStringHandler_Expecter
- type MockStringHandler_Handle_Call
- func (_c *MockStringHandler_Handle_Call) Return(_a0 string, _a1 error) *MockStringHandler_Handle_Call
- func (_c *MockStringHandler_Handle_Call) Run(run func(input string)) *MockStringHandler_Handle_Call
- func (_c *MockStringHandler_Handle_Call) RunAndReturn(run func(string) (string, error)) *MockStringHandler_Handle_Call
- type StringHandler
Constants ¶
const ( CodeAborted = "ABORTED" CodeAlreadyExists = "ALREADY_EXISTS" CodeBufferError = "BUFFER_ERROR" CodeCanceled = "CANCELED" CodeConditionFailed = "CONDITION_FAILED" CodeDatabaseError = "DATABASE_ERROR" CodeExecutionError = "EXECUTION_ERROR" CodeExpired = "EXPIRED" CodeFileError = "FILE_ERROR" CodeFilesystemError = "FILESYSTEM_ERROR" CodeForwardedError = "FORWARDED_ERROR" CodeInternalError = "INTERNAL_ERROR" CodeInvalidValue = "INVALID_VALUE" CodeMissingValue = "MISSING_VALUE" CodeNetworkError = "NETWORK_ERROR" CodeNotFound = "NOT_FOUND" CodeOpenFileError = "OPEN_FILE_ERROR" CodeParseError = "PARSE_ERROR" CodeSerializationError = "SERIALIZATION_ERROR" CodeTypeAssertionError = "TYPE_ASSERTION_ERROR" CodeUnauthenticated = "UNAUTHENTICATED" CodeUnexpectedContent = "UNEXPECTED_CONTENT" CodeUnimplemented = "UNIMPLEMENTED" CodeUnknownError = "UNKNOWN_ERROR" CodeUnsupportedValue = "UNSUPPORTED_VALUE" )
Variables ¶
This section is empty.
Functions ¶
func BaseFuncMap ¶
BaseFuncMap returns a template.FuncMap with sprig's GenericFuncMap and additional utility functions.
func BuildInfo ¶
func BuildInfo() string
BuildInfo returns the static string value that holds information set during build, like app version, build version, etc.
func CheckTestError ¶
CheckTestError verifies that the given error is the expected error and returns true if err is not null and equals want.
func InsertSliceElem ¶
InsertSliceElem inserts element in the given slice and index. If index is negative, it is treated as `index+len(slice)+1`:
- -1 adds to the end of the slice, i.e., appends the element.
- -(len(slice)+1) is the same as index=0: it adds to the beginning of the slice, i.e., prepends the element.
Types ¶
type DeployEnv ¶
type DeployEnv int
const ( // The default, non-ephemeral, deployment environment. DeployEnvProduction DeployEnv = 0 // A remote environment that closely matches production. DeployEnvStaging DeployEnv = 10 // A remote environment to test newly developed features. // Can be used to stress-test the infrastructure. DeployEnvTesting DeployEnv = 20 // A remote environment that is used for automated tests, // usually when changes are pushed to code repositories. DeployEnvCI DeployEnv = 30 // A local environment that is used for automated tests, // usually to ensure tests pass before pushing changes to code repositories. DeployEnvLocalCI DeployEnv = 40 // A local environment that is used for local development or testing. DeployEnvLocal DeployEnv = 50 )
type Error ¶
type Error struct { // A globally unique identifier. ID string `cbor:"1,keyasint,omitempty" json:"id,omitempty"` // The HTTP status code applicable to this problem. This SHOULD be provided. Status int `cbor:"2,keyasint,omitempty" json:"status,omitempty"` // An application-specific error code, expressed as a string value. Code string `cbor:"3,keyasint,omitempty" json:"code,omitempty"` // A label that can be used as a sub error code, or to better identify the error. Label string `cbor:"4,keyasint,omitempty" json:"label,omitempty"` // The path to the error, e.g., the input object's field that caused the error. Path string `cbor:"5,keyasint,omitempty" json:"path,omitempty"` // A short, human-readable summary of the problem that SHOULD NOT change // from occurrence to occurrence of the problem, except for purposes of localization. Title string `cbor:"6,keyasint,omitempty" json:"title,omitempty"` // A human-readable explanation specific to this occurrence of the problem. // Like title, this field’s value can be localized. Detail string `cbor:"7,keyasint,omitempty" json:"detail,omitempty"` // The original error message, from stdlib or external libraries/packages. // This is equivalent to jsonapi's "source" field, although we just care // about the error message, not additional information. Cause string `cbor:"8,keyasint,omitempty" json:"cause,omitempty"` // The amount of time to wait before retrying the request. RetryDelay time.Duration `cbor:"9,keyasint,omitempty" json:"retryDelay,omitempty"` // Available help for the error. Help []*HelpLink `cbor:"10,keyasint,omitempty" json:"help,omitempty"` // An object containing non-standard meta-information about the error. Meta map[string]any `cbor:"11,keyasint,omitempty" json:"meta,omitempty"` }
Inspired by https://jsonapi.org/format/#error-objects.
type ErrorChain ¶
type ErrorChain []*Error
func ForwardError ¶
func ForwardError(id string, err error) ErrorChain
ForwardError wraps and returns the given error as an ErrorChain. The id is used to identify where the forwarding happened.
func (ErrorChain) Add ¶
func (e ErrorChain) Add(err ...*Error) ErrorChain
func (ErrorChain) Error ¶
func (e ErrorChain) Error() string
func (ErrorChain) First ¶
func (e ErrorChain) First() *Error
func (ErrorChain) Last ¶
func (e ErrorChain) Last() *Error
type MockStringHandler ¶
MockStringHandler is an autogenerated mock type for the StringHandler type
func NewMockStringHandler ¶
func NewMockStringHandler(t interface { mock.TestingT Cleanup(func()) }) *MockStringHandler
NewMockStringHandler creates a new instance of MockStringHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockStringHandler) EXPECT ¶
func (_m *MockStringHandler) EXPECT() *MockStringHandler_Expecter
type MockStringHandler_Expecter ¶
type MockStringHandler_Expecter struct {
// contains filtered or unexported fields
}
func (*MockStringHandler_Expecter) Handle ¶
func (_e *MockStringHandler_Expecter) Handle(input interface{}) *MockStringHandler_Handle_Call
Handle is a helper method to define mock.On call
- input string
type MockStringHandler_Handle_Call ¶
MockStringHandler_Handle_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Handle'
func (*MockStringHandler_Handle_Call) Return ¶
func (_c *MockStringHandler_Handle_Call) Return(_a0 string, _a1 error) *MockStringHandler_Handle_Call
func (*MockStringHandler_Handle_Call) Run ¶
func (_c *MockStringHandler_Handle_Call) Run(run func(input string)) *MockStringHandler_Handle_Call
func (*MockStringHandler_Handle_Call) RunAndReturn ¶
func (_c *MockStringHandler_Handle_Call) RunAndReturn(run func(string) (string, error)) *MockStringHandler_Handle_Call
type StringHandler ¶
StringHandler is an interface for processing strings. E.g.: validation, transformation, etc.