Debian Codegraph @

plugin/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 plugin
15
16 import "errors"
17
18 // ErrNotCompliant is returned by plugin methods when the response is not
19 // compliant.
20 var ErrNotCompliant = errors.New("plugin not compliant")
21
22 // ErrNotRegularFile is returned when the plugin file is not an regular file.
23 var ErrNotRegularFile = errors.New("plugin executable file is not a regular file")
24
25 // PluginDowngradeError is returned when installing a plugin with version
26 // lower than the exisiting plugin version.
27 type PluginDowngradeError struct {
28 Msg string
29 }
30
31 // Error returns the error message.
32 func (e PluginDowngradeError) Error() string {
33 if e.Msg != "" {
34 return e.Msg
35 }
36 return "installing plugin with version lower than the existing plugin version"
37 }
38
39 // InstallEqualVersionError is returned when installing a plugin with version
40 // equal to the exisiting plugin version.
41 type InstallEqualVersionError struct {
42 Msg string
43 }
44
45 // Error returns the error message.
46 func (e InstallEqualVersionError) Error() string {
47 if e.Msg != "" {
48 return e.Msg
49 }
50 return "installing plugin with version equal to the existing plugin version"
51 }
52
53 // PluginMalformedError is used when there is an issue with plugin and
54 // should be fixed by plugin developers.
55 type PluginMalformedError struct {
56 Msg string
57 InnerError error
58 }
59
60 // Error returns the error message.
61 func (e PluginMalformedError) Error() string {
62 if e.Msg != "" {
63 return e.Msg
64 }
65 return e.InnerError.Error()
66 }
67
68 // Unwrap returns the inner error.
69 func (e PluginMalformedError) Unwrap() error {
70 return e.InnerError
71 }
72
73 // PluginDirectoryWalkError is used when there is an issue with plugins directory
74 // and should suggest user to check the permission of plugin directory.
75 type PluginDirectoryWalkError error
76
77 // PluginExecutableFileError is used when there is an issue with plugin
78 // executable file and should suggest user to check the existence, permission
79 // and platform/arch compatibility of plugin.
80 type PluginExecutableFileError struct {
81 Msg string
82 InnerError error
83 }
84
85 // Error returns the error message.
86 func (e PluginExecutableFileError) Error() string {
87 if e.Msg != "" {
88 return e.Msg
89 }
90 return e.InnerError.Error()
91 }
92
93 // Unwrap returns the inner error.
94 func (e PluginExecutableFileError) Unwrap() error {
95 return e.InnerError
96 }