MCPcopy Create free account
hub / github.com/arctic-cli/interface / withErrorHandling

Function withErrorHandling

packages/arctic/src/storage/storage.ts:202–216  ·  view source on GitHub ↗
(body: () => Promise<T>)

Source from the content-addressed store, hash-verified

200 }
201
202 async function withErrorHandling<T>(body: () => Promise<T>) {
203 return body().catch((e) => {
204 if (!(e instanceof Error)) throw e
205 const errnoException = e as NodeJS.ErrnoException
206 if (errnoException.code === "ENOENT") {
207 throw new NotFoundError({ message: `Resource not found: ${errnoException.path}` })
208 }
209 // handle JSON parse errors gracefully
210 if (e instanceof SyntaxError && e.message.includes("JSON")) {
211 log.warn("corrupted JSON file, skipping", { error: e.message })
212 throw new NotFoundError({ message: `Corrupted file: ${e.message}` })
213 }
214 throw e
215 })
216 }
217
218 const glob = new Bun.Glob("**/*")
219 export async function list(prefix: string[]) {

Callers 4

removeFunction · 0.85
readFunction · 0.85
updateFunction · 0.85
writeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected