forked from mystiq/hydrogen-web
Migrate error.js to TypeScript
This commit is contained in:
parent
aa9839ee40
commit
28ee87cd2f
3 changed files with 9 additions and 6 deletions
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import {QueryTarget} from "./QueryTarget.js";
|
||||
import {IDBRequestAttemptError} from "./error.js";
|
||||
import {IDBRequestAttemptError} from "./error";
|
||||
|
||||
const LOG_REQUESTS = false;
|
||||
|
||||
|
|
|
@ -18,7 +18,10 @@ limitations under the License.
|
|||
import { StorageError } from "../common";
|
||||
|
||||
export class IDBError extends StorageError {
|
||||
constructor(message, source, cause) {
|
||||
storeName: string;
|
||||
databaseName: string;
|
||||
|
||||
constructor(message: string, source, cause: DOMException | null) {
|
||||
const storeName = source?.name || "<unknown store>";
|
||||
const databaseName = source?.transaction?.db?.name || "<unknown db>";
|
||||
let fullMessage = `${message} on ${databaseName}.${storeName}`;
|
||||
|
@ -34,14 +37,14 @@ export class IDBError extends StorageError {
|
|||
if (cause) {
|
||||
fullMessage += cause.message;
|
||||
}
|
||||
super(fullMessage, cause);
|
||||
super(fullMessage, cause || undefined);
|
||||
this.storeName = storeName;
|
||||
this.databaseName = databaseName;
|
||||
}
|
||||
}
|
||||
|
||||
export class IDBRequestError extends IDBError {
|
||||
constructor(request, message = "IDBRequest failed") {
|
||||
constructor(request: IDBRequest, message: string = "IDBRequest failed") {
|
||||
const source = request.source;
|
||||
const cause = request.error;
|
||||
super(message, source, cause);
|
||||
|
@ -49,7 +52,7 @@ export class IDBRequestError extends IDBError {
|
|||
}
|
||||
|
||||
export class IDBRequestAttemptError extends IDBError {
|
||||
constructor(method, source, cause, params) {
|
||||
constructor(method: string, source, cause: DOMException, params: any[]) {
|
||||
super(`${method}(${params.map(p => JSON.stringify(p)).join(", ")}) failed`, source, cause);
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { IDBRequestError } from "./error.js";
|
||||
import { IDBRequestError } from "./error";
|
||||
import { StorageError } from "../common";
|
||||
|
||||
let needsSyncPromise = false;
|
||||
|
|
Loading…
Reference in a new issue