Sobes.tech
Junior — Senior

Defining your own error type

livecode

Task condition

Create a custom error type and implement the Error() method for it so that it satisfies the standard error interface.

type MyError struct {
    Message string
    Status  int
}

func (e MyError) Error() string {
    return fmt.Sprintf("%s (code %d)", e.Message, e.Status)
}