File: error_112.go

package info (click to toggle)
golang-github-joomcode-errorx 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 280 kB
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// +build !go1.13

package errorx

func isOfType(err error, t *Type) bool {
	e := Cast(err)
	return e != nil && e.IsOfType(t)
}

func (e *Error) isOfType(t *Type) bool {
	cause := e
	for cause != nil {
		if !cause.transparent {
			return cause.errorType.IsOfType(t)
		}

		cause = Cast(cause.Cause())
	}

	return false
}