MCPcopy Index your code
hub / github.com/massCodeIO/massCode / parseStorageError

Function parseStorageError

src/main/api/routes/notes.ts:12–28  ·  view source on GitHub ↗
(
  error: unknown,
)

Source from the content-addressed store, hash-verified

10const app = new Elysia({ prefix: '/notes' })
11
12function parseStorageError(
13 error: unknown,
14): { code: string, message: string } | null {
15 if (!(error instanceof Error)) {
16 return null
17 }
18
19 const separatorIndex = error.message.indexOf(':')
20 if (separatorIndex <= 0) {
21 return null
22 }
23
24 return {
25 code: error.message.slice(0, separatorIndex),
26 message: error.message.slice(separatorIndex + 1).trim(),
27 }
28}
29
30function mapStorageError(status: unknown, error: unknown): never {
31 const setStatus = status as (

Callers 1

mapStorageErrorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected