Skip to main content

Error handling

Wrap your updateRecords() call in a try/catch block to gracefully handle validation errors or transaction failures.

TypeScript
try {
const result = await manta.updateRecords({
table: "products",
data: { name: "ab", price: -10 },
where: { id: 1 },
options: {
validationRule: {
name: { minLength: 3 }, // Fails: length is 2
price: { greaterThan: 0 }, // Fails: price is negative
},
},
});
} catch (error) {
console.error("Update failed:", error.message);
}

Continuing on error

The continueOnError option controls how failures are handled:

  • continueOnError: true: Valid rows are inserted successfully, and a list of detailed errors is returned for the failed rows.
  • continueOnError: false (default): The entire request is aborted immediately upon the first failure.
⚠️Caution

Setting continueOnError to true is not recommended for critical data operations, as it can lead to partial updates where only a subset of your intended changes are applied.

TypeScript
await manta.updateRecords({
table: "products",
data: massiveArray,
where: { status: "active" },
options: {
continueOnError: true,
},
});