/
jre_errors.go
37 lines (29 loc) · 881 Bytes
/
jre_errors.go
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
34
35
36
37
package launcher
import "fmt"
type javaUnavailableErrno int
const (
_ = iota
ErrSystemUnsupported javaUnavailableErrno = iota
ErrVersionUnavailable = iota
)
type JavaUnavailableError struct {
System string
Version string
Errno javaUnavailableErrno
}
func (j *JavaUnavailableError) Error() (text string) {
switch j.Errno {
case ErrSystemUnsupported:
text = fmt.Sprintf("no runtimes support system \"%s\"", j.System)
case ErrVersionUnavailable:
text = fmt.Sprintf("version \"%s\" is not supported on system \"%s\"", j.Version, j.System)
}
return
}
func (j *JavaUnavailableError) Is(target error) bool {
t, ok := target.(*JavaUnavailableError)
return ok &&
(t.System == "" || j.System == t.System) &&
(t.Version == "" || j.Version == t.Version) &&
(t.Errno == 0 || j.Errno == t.Errno)
}