-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
37 lines (32 loc) · 973 Bytes
/
Copy patherrors.go
File metadata and controls
37 lines (32 loc) · 973 Bytes
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 fortimgr
import (
"errors"
"fmt"
"strings"
)
var (
ErrAuth = errors.New("fortimgr: authentication failed")
ErrPermission = errors.New("fortimgr: no permission for resource")
ErrCertificate = errors.New("fortimgr: invalid TLS certificate")
ErrNotLoggedIn = errors.New("fortimgr: not logged in")
ErrInvalidName = errors.New("fortimgr: invalid ADOM or package name")
ErrSessionExpired = errors.New("fortimgr: session expired")
)
// APIError represents a non-zero status code from FortiManager.
type APIError struct {
Code int
Message string
}
func (e *APIError) Error() string {
return fmt.Sprintf("fortimgr: API error %d: %s", e.Code, e.Message)
}
// isCertificateError checks if err is a TLS/x509 certificate error.
func isCertificateError(err error) bool {
if err == nil {
return false
}
s := err.Error()
return strings.Contains(s, "x509:") ||
strings.Contains(s, "certificate") ||
strings.Contains(s, "tls:")
}