[fabric/domain] Simplify StoreQueryError constructor
This commit is contained in:
parent
758f8d933a
commit
6a0be50ef7
@ -1,12 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
|
|
||||||
import { TaggedError } from "@fabric/core";
|
import { TaggedError } from "@fabric/core";
|
||||||
|
|
||||||
export class StoreQueryError extends TaggedError<"StoreQueryError"> {
|
export class StoreQueryError extends TaggedError<"StoreQueryError"> {
|
||||||
constructor(
|
constructor(public message: string) {
|
||||||
public message: string,
|
super("StoreQueryError", message);
|
||||||
public context: any,
|
|
||||||
) {
|
|
||||||
super("StoreQueryError");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export class SQLiteEventStore<TEvents extends Event>
|
|||||||
)`,
|
)`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(error) => new StoreQueryError(error.message, { error }),
|
(error) => new StoreQueryError(error.message),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ export class SQLiteEventStore<TEvents extends Event>
|
|||||||
);
|
);
|
||||||
return events;
|
return events;
|
||||||
},
|
},
|
||||||
(error) => new StoreQueryError(error.message, { error }),
|
(error) => new StoreQueryError(error.message),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,10 +120,7 @@ export class SQLiteEventStore<TEvents extends Event>
|
|||||||
|
|
||||||
return !lastVersion ? 0n : BigInt(lastVersion);
|
return !lastVersion ? 0n : BigInt(lastVersion);
|
||||||
},
|
},
|
||||||
(error) =>
|
(error) => new StoreQueryError(error.message),
|
||||||
new StoreQueryError(`Error getting last version:${error.message}`, {
|
|
||||||
error,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +143,7 @@ export class SQLiteEventStore<TEvents extends Event>
|
|||||||
close(): AsyncResult<void, StoreQueryError> {
|
close(): AsyncResult<void, StoreQueryError> {
|
||||||
return AsyncResult.tryFrom(
|
return AsyncResult.tryFrom(
|
||||||
() => this.db.close(),
|
() => this.db.close(),
|
||||||
(error) => new StoreQueryError(error.message, { error }),
|
(error) => new StoreQueryError(error.message),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +173,7 @@ export class SQLiteEventStore<TEvents extends Event>
|
|||||||
);
|
);
|
||||||
return storedEvent;
|
return storedEvent;
|
||||||
},
|
},
|
||||||
(error) => new StoreQueryError("Error appending event", { error }),
|
(error) => new StoreQueryError(error.message),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,11 +62,7 @@ export class QueryBuilder<T> implements StoreQuery<T> {
|
|||||||
transformRow(this.schema[this.query.from]),
|
transformRow(this.schema[this.query.from]),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(err) =>
|
(err) => new StoreQueryError(err.message),
|
||||||
new StoreQueryError(err.message, {
|
|
||||||
err,
|
|
||||||
query: this.query,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +87,7 @@ export class QueryBuilder<T> implements StoreQuery<T> {
|
|||||||
transformRow(this.schema[this.query.from]),
|
transformRow(this.schema[this.query.from]),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(err) =>
|
(err) => new StoreQueryError(err.message),
|
||||||
new StoreQueryError(err.message, {
|
|
||||||
err,
|
|
||||||
query: this.query,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,12 +52,7 @@ export class SQLiteStateStore<TModel extends Model>
|
|||||||
recordToSQLParams(model, record),
|
recordToSQLParams(model, record),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(error) =>
|
(error) => new StoreQueryError(error.message),
|
||||||
new StoreQueryError(error.message, {
|
|
||||||
error,
|
|
||||||
collectionName: model.name,
|
|
||||||
record,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,12 +82,7 @@ export class SQLiteStateStore<TModel extends Model>
|
|||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(error) =>
|
(error) => new StoreQueryError(error.message),
|
||||||
new StoreQueryError(error.message, {
|
|
||||||
error,
|
|
||||||
collectionName: model.name,
|
|
||||||
record,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,12 +99,7 @@ export class SQLiteStateStore<TModel extends Model>
|
|||||||
{ $id: id },
|
{ $id: id },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(error) =>
|
(error) => new StoreQueryError(error.message),
|
||||||
new StoreQueryError(error.message, {
|
|
||||||
error,
|
|
||||||
collectionName: model.name,
|
|
||||||
id,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,11 +115,7 @@ export class SQLiteStateStore<TModel extends Model>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(error) =>
|
(error) => new StoreQueryError(error.message),
|
||||||
new StoreQueryError(error.message, {
|
|
||||||
error,
|
|
||||||
schema: this.schema,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user