Welcome to mirror list, hosted at ThFree Co, Russian Federation.

errors.go « vfs « internal - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 31ad895df4976b41f4159fb1a4ed463a5d25b694 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package vfs

import "fmt"

const message = "An error occurred while trying to read vfs.File content"

type ReadError struct {
	wrapped error
}

func NewReadError(wrapped error) *ReadError {
	return &ReadError{
		wrapped: wrapped,
	}
}

func (r *ReadError) Error() string {
	if r.wrapped == nil {
		return message
	}

	return fmt.Sprintf("%s: %s", message, r.wrapped.Error())
}

func (r *ReadError) Unwrap() error {
	return r.wrapped
}

func (r *ReadError) Is(target error) bool {
	//nolint: errorlint // implementing type equality for errors.Is
	_, ok := target.(*ReadError)
	return ok
}