MCPcopy
hub / github.com/tinode/chat / decodeStoreErrorExplicitTs

Function decodeStoreErrorExplicitTs

server/utils.go:176–225  ·  view source on GitHub ↗
(err error, id, topic string, serverTs, incomingReqTs time.Time,
	params map[string]any)

Source from the content-addressed store, hash-verified

174}
175
176func decodeStoreErrorExplicitTs(err error, id, topic string, serverTs, incomingReqTs time.Time,
177 params map[string]any) *ServerComMessage {
178
179 var errmsg *ServerComMessage
180
181 if err == nil {
182 errmsg = NoErrExplicitTs(id, topic, serverTs, incomingReqTs)
183 } else if storeErr, ok := err.(types.StoreError); !ok {
184 errmsg = ErrUnknownExplicitTs(id, topic, serverTs, incomingReqTs)
185 } else {
186 switch storeErr {
187 case types.ErrInternal:
188 errmsg = ErrUnknownExplicitTs(id, topic, serverTs, incomingReqTs)
189 case types.ErrMalformed:
190 errmsg = ErrMalformedExplicitTs(id, topic, serverTs, incomingReqTs)
191 case types.ErrFailed:
192 errmsg = ErrAuthFailed(id, topic, serverTs, incomingReqTs)
193 case types.ErrPermissionDenied:
194 errmsg = ErrPermissionDeniedExplicitTs(id, topic, serverTs, incomingReqTs)
195 case types.ErrDuplicate:
196 errmsg = ErrDuplicateCredential(id, topic, serverTs, incomingReqTs)
197 case types.ErrUnsupported:
198 errmsg = ErrNotImplemented(id, topic, serverTs, incomingReqTs)
199 case types.ErrExpired:
200 errmsg = ErrAuthFailed(id, topic, serverTs, incomingReqTs)
201 case types.ErrPolicy:
202 errmsg = ErrPolicyExplicitTs(id, topic, serverTs, incomingReqTs)
203 case types.ErrCredentials:
204 errmsg = InfoValidateCredentialsExplicitTs(id, serverTs, incomingReqTs)
205 case types.ErrUserNotFound:
206 errmsg = ErrUserNotFound(id, topic, serverTs, incomingReqTs)
207 case types.ErrTopicNotFound:
208 errmsg = ErrTopicNotFound(id, topic, serverTs, incomingReqTs)
209 case types.ErrNotFound:
210 errmsg = ErrNotFoundExplicitTs(id, topic, serverTs, incomingReqTs)
211 case types.ErrInvalidResponse:
212 errmsg = ErrInvalidResponse(id, topic, serverTs, incomingReqTs)
213 case types.ErrRedirected:
214 errmsg = InfoUseOther(id, topic, params["topic"].(string), serverTs, incomingReqTs)
215 default:
216 errmsg = ErrUnknownExplicitTs(id, topic, serverTs, incomingReqTs)
217 }
218 }
219
220 if params != nil {
221 errmsg.Ctrl.Params = params
222 }
223
224 return errmsg
225}
226
227// Helper function to select access mode for the given auth level
228func selectAccessMode(authLvl auth.Level, anonMode, authMode, rootMode types.AccessMode) types.AccessMode {

Callers 11

topicInitFunction · 0.85
decodeStoreErrorFunction · 0.85
replyOfflineTopicGetDescFunction · 0.85
replyOfflineTopicGetSubFunction · 0.85
replyOfflineTopicSetSubFunction · 0.85
replyGetSubMethod · 0.85
replyGetTagsMethod · 0.85
replyGetCredsMethod · 0.85
replySetCredMethod · 0.85
replySetAuxMethod · 0.85
replyDelCredMethod · 0.85

Calls 14

NoErrExplicitTsFunction · 0.85
ErrUnknownExplicitTsFunction · 0.85
ErrMalformedExplicitTsFunction · 0.85
ErrAuthFailedFunction · 0.85
ErrDuplicateCredentialFunction · 0.85
ErrNotImplementedFunction · 0.85
ErrPolicyExplicitTsFunction · 0.85
ErrUserNotFoundFunction · 0.85
ErrTopicNotFoundFunction · 0.85
ErrNotFoundExplicitTsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…