Skip to content

Commit bdb118e

Browse files
committed
Add clearer error message for DbChange validation
1 parent 439cb89 commit bdb118e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

packages/common/src/local-first/Evolu.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
isNonEmptyArray,
55
isNonEmptyReadonlyArray,
66
} from "../Array.js";
7-
import { assertNonEmptyReadonlyArray } from "../Assert.js";
7+
import { assert, assertNonEmptyReadonlyArray } from "../Assert.js";
88
import { createCallbacks } from "../Callbacks.js";
99
import { ConsoleDep } from "../Console.js";
1010
import { RandomBytesDep, SymmetricCryptoDecryptError } from "../Crypto.js";
@@ -730,13 +730,18 @@ const createEvoluInstance =
730730
} else {
731731
const { id: _, isDeleted, ...values } = result.value;
732732

733-
const dbChange = DbChange.orThrow({
733+
const dbChange = {
734734
table,
735735
id,
736736
values,
737737
isInsert: kind === "insert" || kind === "upsert",
738738
isDelete: SqliteBoolean.is(isDeleted) ? Boolean(isDeleted) : null,
739-
});
739+
};
740+
741+
assert(
742+
DbChange.is(dbChange),
743+
`Invalid DbChange for table '${table}': Please check schema type errors.`,
744+
);
740745

741746
mutateMicrotaskQueue.push([
742747
{ ...dbChange, ownerId: options?.ownerId },

0 commit comments

Comments
 (0)