-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy patherrors.go
66 lines (53 loc) · 1.92 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 ycq
import "fmt"
// ErrCommandExecution is the error returned in response to a failed command.
type ErrCommandExecution struct {
Command CommandMessage
Reason string
}
// Error fulfills the error interface.
func (e *ErrCommandExecution) Error() string {
return fmt.Sprintf("Invalid Operation. Command: %s Reason: %s", e.Command.CommandType(), e.Reason)
}
// ErrConcurrencyViolation is returned when a concurrency error is raised by the event store
// when events are persisted to a stream and the version of the stream does not match
// the expected version.
type ErrConcurrencyViolation struct {
Aggregate AggregateRoot
ExpectedVersion *int
StreamName string
}
func (e *ErrConcurrencyViolation) Error() string {
return fmt.Sprintf("ConcurrencyError: AggregateID: %s ExpectedVersion: %d StreamName: %s", e.Aggregate.AggregateID(), *e.ExpectedVersion, e.StreamName)
}
// ErrUnauthorized is returned when a request to the repository is not authorized
type ErrUnauthorized struct {
}
func (e *ErrUnauthorized) Error() string {
return "Not authorized."
}
// ErrUnexpected is returned for all errors that are not otherwise represented
// explicitly.
//
// The original error is available for inspection in the Err field.
type ErrUnexpected struct {
Err error
}
func (e *ErrUnexpected) Error() string {
return fmt.Sprintf("An unepected error occurred. %s", e.Err)
}
// ErrRepositoryUnavailable is returned when the eventstore is temporarily unavailable
type ErrRepositoryUnavailable struct{}
func (e *ErrRepositoryUnavailable) Error() string {
return "The repository is temporarily unavailable."
}
// ErrAggregateNotFound error returned when an aggregate was not found in the repository.
type ErrAggregateNotFound struct {
AggregateID string
AggregateType string
}
func (e *ErrAggregateNotFound) Error() string {
return fmt.Sprintf("Could not find any aggregate of type %s with id %s",
e.AggregateType,
e.AggregateID)
}