MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / wrapCollectionNotFound

Function wrapCollectionNotFound

internal/cli/collection_alias.go:111–121  ·  view source on GitHub ↗

wrapCollectionNotFound rewrites the server's context-free "Collection not found" into one that names the slug the user actually typed, so a failed `pad item create widget …` reads `collection "widget" not found` instead of a bare "Collection not found". It returns a fresh *APIError with the same Cod

(err error, rawSlug string)

Source from the content-addressed store, hash-verified

109// working) and an enriched Message. Non-collection errors pass through
110// untouched. Mirrors wrapItemNotFound's shape.
111func wrapCollectionNotFound(err error, rawSlug string) error {
112 var apiErr *APIError
113 if errors.As(err, &apiErr) && isCollectionNotFound(err) {
114 return &APIError{
115 Code: apiErr.Code,
116 Message: fmt.Sprintf("collection %q not found", rawSlug),
117 Details: apiErr.Details,
118 }
119 }
120 return err
121}
122
123// isCollectionNotFound reports whether err is the server's specific
124// "collection not found" response for an item create / list / move request. It

Callers 1

Calls 1

isCollectionNotFoundFunction · 0.85

Tested by

no test coverage detected