* Produces a new onerror handler for IDB. Our errors are always fatal, so we * handle them generically: Call the user-supplied callback with a translated * version of the error, and let the error bubble up. * @hidden
(cb: (e: ApiError) => void, code: ErrorCode = ErrorCode.EIO, message: string | null = null)
| 36 | * @hidden |
| 37 | */ |
| 38 | function onErrorHandler(cb: (e: ApiError) => void, code: ErrorCode = ErrorCode.EIO, message: string | null = null): (e?: any) => void { |
| 39 | return function(e?: any): void { |
| 40 | // Prevent the error from canceling the transaction. |
| 41 | e.preventDefault(); |
| 42 | cb(new ApiError(code, message !== null ? message : undefined)); |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @hidden |