-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
31 lines (25 loc) · 931 Bytes
/
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
package cbus
import "fmt"
//HandlerNotFoundError occurs when a Handler has not been registered for a Command's type.
type HandlerNotFoundError struct {
//Command is the Command that a Handler was not found for.
Command
}
//Error is the error implementation.
func (e *HandlerNotFoundError) Error() string {
return fmt.Sprintf("cbus: Handler not found for Command type %T", e.Command)
}
//IsHandlerNotFoundError determines whether or not err is of type *HandlerNotFoundError.
func IsHandlerNotFoundError(err error) bool {
_, ok := err.(*HandlerNotFoundError)
return ok
}
//ExecutionPanicError occurs when a Handler or Listener panics during execution.
type ExecutionPanicError struct {
//Panic is the value received from recover() if not nil.
Panic interface{}
}
//Error is the error implementation.
func (e *ExecutionPanicError) Error() string {
return fmt.Sprintf("cbus: panic while executing command %v", e.Panic)
}