Invental/Review lessons/Writes that span systems

Writes that span systems

Say what state each failed step left behind

A rollback is only as good as its error messages: each failure point in a multi-step remote change must say exactly what state it left, or the user's “fix” makes things worse.

01 · Before and afterThe pattern

TypeScript
await api.delete(old.id);
try {
  await api.create(next);
} catch (err) {
  try { await api.create(old); }                  // restore from the copy we read first
  catch { throw new Error(`Lost ${old.type} ${old.name} -> ${old.target}; recreate it`); }
  throw err;                                       // the original reason still wins
}
try { await api.publish(zone); }
catch { throw new Error("Saved, not yet published; do not redo it"); }

02 · Run it on your appThe check

When step two of a two-step change to an external system fails, does your app tell the user what state step one left?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.