Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
Latest commit
72 lines (57 loc) · 1.58 KB
/
Copy patherrors.go
File metadata and controls
72 lines (57 loc) · 1.58 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package commanderrors
import (
"fmt"
"github.com/Postcord/router"
)
// CommandError is an error that is returned when a command fails
typeCommandErrorinterface {
Error() string
Command() string
}
// ErrRuntime represents a generic runtime error
typeErrRuntimestruct {
cmd*router.Command
Valuestring
}
funcNewErrRuntime(command*router.Command, valuestring) *ErrRuntime {
return&ErrRuntime{
cmd: command,
Value: value,
}
}
func (e*ErrRuntime) Error() string {
returnfmt.Sprintf("Error (%s): %s", e.Command(), e.Value)
}
func (e*ErrRuntime) Command() string {
returne.cmd.Name
}
// ErrCommandNotImplemented is an error that is returned when a command is not implemented
typeErrCommandNotImplementedstruct {
cmd*router.Command
}
funcNewErrCommandNotImplemented(command*router.Command) *ErrCommandNotImplemented {
return&ErrCommandNotImplemented{
cmd: command,
}
}
func (e*ErrCommandNotImplemented) Error() string {
returnfmt.Sprintf("Command %s not implemented", e.Command())
}
func (e*ErrCommandNotImplemented) Command() string {
returne.cmd.Name
}
// ErrCommandNotAllowed is an error that is returned when the running user is not currently allowed to run a command
typeErrCommandNotAllowedstruct {
cmd*router.Command
}
funcNewErrCommandNotAllowed(command*router.Command) *ErrCommandNotAllowed {
return&ErrCommandNotAllowed{
cmd: command,
}
}
func (e*ErrCommandNotAllowed) Error() string {
returnfmt.Sprintf("You are not allowed to run %s at this time.", e.Command())
}
func (e*ErrCommandNotAllowed) Command() string {
returne.cmd.Name
}