local-server/errors.go
2018-06-12 21:09:47 +11:00

30 lines
356 B
Go

package main
import (
"fmt"
"os"
)
type notFoundError struct {
ref string
}
func (e notFoundError) Error() string {
return fmt.Sprintf("not found: %s", e.ref)
}
var _ error = notFoundError{}
func isNotFound(err error) bool {
if err == nil {
return false
}
if os.IsNotExist(err) {
return true
}
_, ok := err.(notFoundError)
return ok
}