-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy patherrors.go
More file actions
43 lines (35 loc) · 1.1 KB
/
Copy patherrors.go
File metadata and controls
43 lines (35 loc) · 1.1 KB
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
38
39
40
41
42
43
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package bootstrap
import (
"errors"
"fmt"
)
type ErrorType string
const (
ErrorTypeGetAccessTokenFailure ErrorType = "GetAccessTokenFailure"
ErrorTypeGetServiceClientFailure ErrorType = "GetServiceClientFailure"
ErrorTypeGetInstanceDataFailure ErrorType = "GetInstanceDataFailure"
ErrorTypeGetAttestedDataFailure ErrorType = "GetAttestedDataFailure"
ErrorTypeGetNonceFailure ErrorType = "GetNonceFailure"
ErrorTypeGetCSRFailure ErrorType = "GetCSRFailure"
ErrorTypeGetCredentialFailure ErrorType = "GetCredentialFailure"
ErrorTypeGenerateKubeconfigFailure ErrorType = "GenerateKubeconfigFailure"
)
type bootstrapError struct {
errorType ErrorType
inner error
}
func (e *bootstrapError) Error() string {
return fmt.Sprintf("%s: %s", e.errorType, e.inner.Error())
}
func (e *bootstrapError) Unwrap() error {
return e.inner
}
func GetErrorType(err error) ErrorType {
var bootstrapErr *bootstrapError
if !errors.As(err, &bootstrapErr) {
return ""
}
return bootstrapErr.errorType
}