package main

import (
    "fmt"
    "errors"
)

type MyError struct {
    Err error
    Detail string
}

func (e MyError) Error() string {
    s := e.Err.Error()
    if e.Detail != "" {
        s += " " + e.Detail
    }

    return s
}

func (e MyError) Unwrap() error {
    return e.Err
}

var (
    firstError = errors.New("first error")
    secondError = errors.New("second error")
)

func main() {
    e := MyError{Err: firstError, Detail: "Hello world!"}
    fmt.Println(e)
    fmt.Printf("it is an instance of firstError: %v\n", errors.Is(e, firstError))

    isMyError := errors.As(e, &MyError{})    
    fmt.Printf("it is an instance of MyError: %v\n", isMyError)
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: