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