-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
37 lines (30 loc) · 1.21 KB
/
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
// Copyright 2021-2024 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package psatoken
import (
"errors"
"fmt"
)
var (
ErrMissingOptional = errors.New("missing optional")
ErrMissingMandatory = errors.New("missing mandatory")
ErrNotInProfile = errors.New("not in profile")
ErrWrongProfile = errors.New("wrong profile")
ErrWrongSyntax = errors.New("wrong syntax")
ErrOptionalClaimMissing = fmt.Errorf("%w claim", ErrMissingOptional)
ErrMandatoryClaimMissing = fmt.Errorf("%w claim", ErrMissingMandatory)
ErrClaimNotInProfile = fmt.Errorf("claim %w", ErrNotInProfile)
ErrOptionalFieldMissing = fmt.Errorf("%w field", ErrMissingOptional)
ErrMandatoryFieldMissing = fmt.Errorf("%w field", ErrMissingMandatory)
ErrFieldNotInProfile = fmt.Errorf("field %w", ErrNotInProfile)
)
// FilterError takes the output of IClaims getters and returns only the
// error, suppressing errors that do not indicate problems in the context of
// the IClaims' profile (i.e. missing optional claims, or claims not supported
// by the profile).
func FilterError(v interface{}, e error) error {
if errors.Is(e, ErrMissingOptional) || errors.Is(e, ErrNotInProfile) {
return nil
}
return e
}