MCPcopy
hub / github.com/jvilk/BrowserFS / convertError

Function convertError

src/backend/IndexedDB.ts:20–30  ·  view source on GitHub ↗

* Converts a DOMException or a DOMError from an IndexedDB event into a * standardized BrowserFS API error. * @hidden

(e: {name: string}, message: string = e.toString())

Source from the content-addressed store, hash-verified

18 * @hidden
19 */
20function 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

Callers 5

getMethod · 0.70
putMethod · 0.70
delMethod · 0.70
abortMethod · 0.70
clearMethod · 0.70

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected