Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogSeq ¶
LogSeq prints a title and a sequence of strings. Each element of the sequence is written in a new line.
However, only the title uses the logger's flags since the sequence itself uses logger.Writer() writer instead.
Parameters:
- logger: The logger to use.
- title: The title to print.
- seq: The sequence to print.
Returns:
- error: An error if printing failed.
Errors:
- errors.ErrNilParameter: when the logger is nil.
- ErrPrintFailed: when the logger failed to print an element.
Behaviors:
- Prints the title if it is not empty. Same goes for seq when it is nil.
- To add an empty line at the end, use _ = yield("\n") in seq.
func NewErrPrintFailed ¶
NewErrPrintFailed creates a new ErrPrintFailed error.
Parameters:
- idx: The index of the element that failed to print.
- reason: The reason for the failure.
Returns:
- error: The new error. Never returns nil.
Format:
"could not print the <ordinal> element: <reason>"
Where: - <ordinal>: The ordinal of the index + 1 according to humanize.Ordinal - <reason>: The reason for the failure. If nil, "something went wrong" is used instead.
Types ¶
type ErrPrintFailed ¶
type ErrPrintFailed struct { // Idx is the index of the element that failed to print. Idx int // Reason is the reason for the failure. Reason error }
ErrPrintFailed is an error that is returned when printing failed.
func (ErrPrintFailed) Error ¶
func (e ErrPrintFailed) Error() string
Error implements the error interface.
Click to show internal directories.
Click to hide internal directories.