serrors

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 2 Imported by: 0

README

serrors

Create error to pass to slog.

See documents

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attributes

func Attributes(err error) []any

func Format

func Format(format string, arguments ...any) func(...any) *Error
Example
package main

import (
	"log/slog"

	"github.com/golang-mods/serrors"
)

func main() {
	err := serrors.New("message", "foo", "bar")
	err = serrors.Format("%w: %s", err, "test")("baz", 1)

	slog.Error(err.Error(), serrors.Attributes(err)...)
}

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

func New

func New(message string, attributes ...any) *Error
Example
package main

import (
	"log/slog"

	"github.com/golang-mods/serrors"
)

func main() {
	err := serrors.New("message", "foo", "bar")

	slog.Error(err.Error(), serrors.Attributes(err)...)
}

func (*Error) Error

func (err *Error) Error() string

func (*Error) Unwrap

func (err *Error) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL