-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
209 lines (164 loc) · 5.15 KB
/
Copy patherrors.go
File metadata and controls
209 lines (164 loc) · 5.15 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Copyright (c) 2019 - Ray Ruan <falconray@yahoo.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fsm
import (
"strconv"
)
const (
UnknownStateStr = "unknownState"
UnknownEventStr = "unknownEvent"
)
type DuplicateCallbackEnterStateError struct {
state string
}
func (e DuplicateCallbackEnterStateError) Error() string {
return "duplicate callback of enter state " + e.state
}
type DuplicateCallbackLeaveStateError struct {
state string
}
func (e DuplicateCallbackLeaveStateError) Error() string {
return "duplicate callback of leave state " + e.state
}
type DuplicateCallbackAfterEventError struct {
event string
}
func (e DuplicateCallbackAfterEventError) Error() string {
return "duplicate callback of after event " + e.event
}
type DuplicateCallbackBeforeEventError struct {
event string
}
func (e DuplicateCallbackBeforeEventError) Error() string {
return "duplicate callback of before event " + e.event
}
type DuplicateCallbackError struct {
}
func (e DuplicateCallbackError) Error() string {
return "duplicate callback register"
}
type DuplicateTransitionError struct {
event string
state string
}
func (e DuplicateTransitionError) Error() string {
return "duplicate transition from { " + e.event + ", " + e.state + " }"
}
type StateStartReserveError struct {
}
func (e StateStartReserveError) Error() string {
return `State {ID:0, Name:"StateStart"} reserve for all state callback Index`
}
type StateStartReserveMissingError struct {
}
func (e StateStartReserveMissingError) Error() string {
return `State {StateID:fsm.StateStartID, Name:fsm.StateStartStr} reserve and should be included in stateMap`
}
type EventStartReserveMissingError struct {
}
func (e EventStartReserveMissingError) Error() string {
return `Event {EventID:fsm.EventStartID, Name:fsm.EventStartStr} reserve and should be included in eventMap`
}
type EventStartReserveError struct {
}
func (e EventStartReserveError) Error() string {
return `Event {ID:0, Name:"EventStart"} reserve for all event callback Index`
}
type EventOutOfRangeError struct {
ID EventID
}
func (e EventOutOfRangeError) Error() string {
return "eventID " + strconv.Itoa(e.ID) + " out of the range"
}
type StateOutOfRangeError struct {
ID StateID
}
func (e StateOutOfRangeError) Error() string {
return "stateID " + strconv.Itoa(e.ID) + " out of the range"
}
type CallbackTypeOutOfRangeError struct {
Type int
}
func (e CallbackTypeOutOfRangeError) Error() string {
return "callback type " + strconv.Itoa(e.Type) + " out of the range"
}
// InvalidEventError is returned by FSM.Event() when the event cannot be called
// in the current state.
type InvalidEventError struct {
Event string
State string
}
func (e InvalidEventError) Error() string {
return "event " + e.Event + " inappropriate in current state " + e.State
}
// UnknownEventError is returned by FSM.Event() when the event is not defined.
type UnknownEventError struct {
Event string
}
func (e UnknownEventError) Error() string {
return "event " + e.Event + " does not exist"
}
// InTransitionError is returned by FSM.Event() when an asynchronous transition
// is already in progress.
type InTransitionError struct {
Event string
}
func (e InTransitionError) Error() string {
return "event " + e.Event + " inappropriate because previous transition did not complete"
}
// NotInTransitionError is returned by FSM.Transition() when an asynchronous
// transition is not in progress.
type NotInTransitionError struct{}
func (e NotInTransitionError) Error() string {
return "transition inappropriate because no state change in progress"
}
// NoTransitionError is returned by FSM.Event() when no transition have happened,
// for example if the source and destination states are the same.
type NoTransitionError struct {
Err error
}
func (e NoTransitionError) Error() string {
if e.Err != nil {
return "no transition with error: " + e.Err.Error()
}
return "no transition"
}
// CanceledError is returned by FSM.Event() when a callback have canceled a
// transition.
type CanceledError struct {
Err error
}
func (e CanceledError) Error() string {
if e.Err != nil {
return "transition canceled with error: " + e.Err.Error()
}
return "transition canceled"
}
// AsyncError is returned by FSM.Event() when a callback have initiated an
// asynchronous state transition.
type AsyncError struct {
Err error
}
func (e AsyncError) Error() string {
if e.Err != nil {
return "async started with error: " + e.Err.Error()
}
return "async started"
}
// InternalError is returned by FSM.Event() and should never occur. It is a
// probably because of a bug.
type InternalError struct{}
func (e InternalError) Error() string {
return "internal error on state transition"
}