Debian Codegraph @

verifier/truststore/errors.go

raw
1 // Copyright The Notary Project Authors.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package truststore
15
16 // TrustStoreError is used when accessing specified trust store failed
17 type TrustStoreError struct {
18 Msg string
19 InnerError error
20 }
21
22 func (e TrustStoreError) Error() string {
23 if e.Msg != "" {
24 return e.Msg
25 }
26 if e.InnerError != nil {
27 return e.InnerError.Error()
28 }
29 return "unable to access the trust store"
30 }
31
32 func (e TrustStoreError) Unwrap() error {
33 return e.InnerError
34 }
35
36 // CertificateError is used when reading a certificate failed
37 type CertificateError struct {
38 Msg string
39 InnerError error
40 }
41
42 func (e CertificateError) Error() string {
43 if e.Msg != "" {
44 return e.Msg
45 }
46 if e.InnerError != nil {
47 return e.InnerError.Error()
48 }
49 return "unable to read the certificate"
50 }
51
52 func (e CertificateError) Unwrap() error {
53 return e.InnerError
54 }