-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrors_generated.go
48 lines (40 loc) · 1.16 KB
/
errors_generated.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
38
39
40
41
42
43
44
45
46
47
48
package katapult
import (
"encoding/json"
"fmt"
)
// Code generated by github.com/krystal/go-katapult/tools/codegen. DO NOT EDIT.
var ErrScopeNotGranted = fmt.Errorf("%w: scope_not_granted", ErrForbidden)
// ScopeNotGrantedError:
// The scope required for this endpoint has not been granted to the authenticating identity.
type ScopeNotGrantedError struct {
CommonError
Detail *ScopeNotGrantedErrorDetail `json:"detail,omitempty"`
}
func NewScopeNotGrantedError(theError *ResponseError) *ScopeNotGrantedError {
detail := &ScopeNotGrantedErrorDetail{}
err := json.Unmarshal(theError.Detail, detail)
if err != nil {
detail = nil
}
return &ScopeNotGrantedError{
CommonError: NewCommonError(
ErrScopeNotGranted,
"scope_not_granted",
theError.Description,
),
Detail: detail,
}
}
type ScopeNotGrantedErrorDetail struct {
Scopes []string `json:"scopes,omitempty"`
}
// castResponseError casts a *katapult.ResponseError to a more specific type based on the error's Code value.
func castResponseError(theError *ResponseError) error {
switch theError.Code {
case "scope_not_granted":
return NewScopeNotGrantedError(theError)
default:
return theError
}
}