-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrors.go
66 lines (52 loc) · 2.34 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
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
package query
import "fmt"
// ErrorInvalidQuery is used when invalid queries are handled.
type ErrorInvalidQuery string
// Error returns the string message of ErrorInvalidQuery.
func (e ErrorInvalidQuery) Error() string {
return string(e)
}
// ErrorBusNotInitialized is used when queries are handled but the bus is not initialized.
type ErrorBusNotInitialized string
// Error returns the string message of ErrorBusNotInitialized.
func (e ErrorBusNotInitialized) Error() string {
return string(e)
}
// ErrorBusIsShuttingDown is used when queries are handled but the bus is shutting down.
type ErrorBusIsShuttingDown string
// Error returns the string message of ErrorBusIsShuttingDown.
func (e ErrorBusIsShuttingDown) Error() string {
return string(e)
}
// ErrorNoQueryHandlersFound is used when not a single handler is found for a specific query.
type ErrorNoQueryHandlersFound struct {
query Query
}
// Error returns the string message of ErrorNoQueryHandlersFound.
func (e ErrorNoQueryHandlersFound) Error() string {
return fmt.Sprintf("query: no handlers were found for the query %T", e.query)
}
// NewErrorNoQueryHandlersFound creates a new ErrorNoQueryHandlersFound.
func NewErrorNoQueryHandlersFound(query Query) ErrorNoQueryHandlersFound {
return ErrorNoQueryHandlersFound{query: query}
}
// ErrorQueryTimedOut is used when the handling of a query times out.
type ErrorQueryTimedOut struct {
query Query
}
// Error returns the string message of ErrorQueryTimedOut.
func (e ErrorQueryTimedOut) Error() string {
return fmt.Sprintf("query: the query %T timed out due to lack of result listeners. This may happen if a query was issued but the \"Iterate\" function of the result was not handled", e.query)
}
// NewErrorQueryTimedOut creates a new ErrorQueryTimedOut.
func NewErrorQueryTimedOut(query Query) ErrorQueryTimedOut {
return ErrorQueryTimedOut{query: query}
}
const (
// InvalidQueryError is a constant equivalent of the ErrorInvalidQuery error.
InvalidQueryError = ErrorInvalidQuery("query: invalid query")
// BusNotInitializedError is a constant equivalent of the ErrorBusNotInitialized error.
BusNotInitializedError = ErrorBusNotInitialized("query: the bus is not initialized")
// BusIsShuttingDownError is a constant equivalent of the ErrorBusIsShuttingDown error.
BusIsShuttingDownError = ErrorBusIsShuttingDown("query: the bus is shutting down")
)