( error: unknown, )
| 25 | ]) |
| 26 | |
| 27 | function parseStorageError( |
| 28 | error: unknown, |
| 29 | ): { code: string, message: string } | null { |
| 30 | if (!(error instanceof Error)) { |
| 31 | return null |
| 32 | } |
| 33 | |
| 34 | const separatorIndex = error.message.indexOf(':') |
| 35 | if (separatorIndex <= 0) { |
| 36 | return null |
| 37 | } |
| 38 | |
| 39 | return { |
| 40 | code: error.message.slice(0, separatorIndex), |
| 41 | message: error.message.slice(separatorIndex + 1).trim(), |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | function mapStorageError(status: unknown, error: unknown): never { |
| 46 | const setStatus = status as ( |