Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MultiError ¶
type MultiError struct {
Errors []error // Errors is a slice storing individual error instances.
}
MultiError represents a collection of errors. It aggregates multiple error values into a single error entity. This is useful for handling multiple errors as a single error.
func NewMultiError ¶
func NewMultiError(errs ...error) *MultiError
NewMultiError creates a new MultiError with the provided errors. It initializes a MultiError with a slice of errors passed as arguments.
Parameters: - errs: ...error A variadic list of errors to be included in the new MultiError.
Returns: - *MultiError: A pointer to the newly created MultiError initialized with the given errors.
func (*MultiError) Add ¶
func (m *MultiError) Add(err error)
Add adds an error to the MultiError. If the provided error is not nil, it is appended to the MultiError's Errors slice.
Parameters: - err: error The error to be added to the MultiError.
func (*MultiError) Count ¶
func (m *MultiError) Count() int
Count returns the number of errors in the MultiError. It provides a quick way to check the number of errors aggregated in the MultiError.
Returns: - int: The count of non-nil errors in the MultiError's Errors slice.
func (*MultiError) Del ¶
func (m *MultiError) Del(index int)
Del deletes an error at the specified index from the MultiError. It safely removes an error by index without causing a panic, even if the index is out of range.
Parameters: - index: int The index of the error to be deleted in the MultiError's Errors slice.
func (*MultiError) Error ¶
func (m *MultiError) Error() string
Error returns a string representation of the MultiError. It concatenates the string representations of all contained errors, separated by semicolons. This method implements the error interface for MultiError.
Returns: - string: A combined string representation of all errors in the MultiError.
func (*MultiError) IsError ¶
func (m *MultiError) IsError() error
IsError checks if the MultiError contains any errors. This method allows for easy checking of the presence of non-nil errors in MultiError. It returns the MultiError itself if it contains any non-nil errors, otherwise nil.
Returns: - error: The MultiError itself if it contains non-nil errors, otherwise nil.