* Converts a DOMException or a DOMError from an IndexedDB event into a * standardized BrowserFS API error. * @hidden
(e: {name: string}, message: string = e.toString())
| 18 | * @hidden |
| 19 | */ |
| 20 | function convertError(e: {name: string}, message: string = e.toString()): ApiError { |
| 21 | switch (e.name) { |
| 22 | case "NotFoundError": |
| 23 | return new ApiError(ErrorCode.ENOENT, message); |
| 24 | case "QuotaExceededError": |
| 25 | return new ApiError(ErrorCode.ENOSPC, message); |
| 26 | default: |
| 27 | // The rest do not seem to map cleanly to standard error codes. |
| 28 | return new ApiError(ErrorCode.EIO, message); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Produces a new onerror handler for IDB. Our errors are always fatal, so we |