MCPcopy Create free account
hub / github.com/blobcache/blobcache / parseWireError

Function parseWireError

src/bcp/message.go:244–275  ·  view source on GitHub ↗
(code MessageCode, x []byte)

Source from the content-addressed store, hash-verified

242}
243
244func parseWireError(code MessageCode, x []byte) error {
245 var ret error
246 switch code {
247 case MT_ERROR_INVALID_HANDLE:
248 var e blobcache.ErrInvalidHandle
249 if err := json.Unmarshal(x, &e); err != nil {
250 return err
251 }
252 ret = &e
253 case MT_ERROR_NOT_FOUND:
254 var e blobcache.ErrNotFound
255 if err := json.Unmarshal(x, &e); err != nil {
256 return err
257 }
258 ret = &e
259 case MT_ERROR_NO_LINK:
260 var e blobcache.ErrNoLink
261 if err := json.Unmarshal(x, &e); err != nil {
262 return err
263 }
264 ret = &e
265 case MT_ERROR_NO_PERMISSION:
266 var e blobcache.ErrPermission
267 if err := json.Unmarshal(x, &e); err != nil {
268 return err
269 }
270 ret = &e
271 default:
272 return fmt.Errorf("unknown error code: %d. data=%q", code, string(x))
273 }
274 return ret
275}
276
277func jsonMarshal(x any) []byte {
278 buf, err := json.Marshal(x)

Callers 4

PostFunction · 0.85
GetFunction · 0.85
doAskFunction · 0.85
TestPermissionWireErrorFunction · 0.85

Calls 1

UnmarshalMethod · 0.65

Tested by 1

TestPermissionWireErrorFunction · 0.68