| 10 | const app = new Elysia({ prefix: '/notes' }) |
| 11 | |
| 12 | function 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 | |
| 30 | function mapStorageError(status: unknown, error: unknown): never { |
| 31 | const setStatus = status as ( |