A stack trace shows the call path that led to an exception. Start with the first frame in your own code rather than guessing from the final error message or changing several things at once.

Make the failure repeatable

  • Record the route, input, and action that trigger the error.
  • Enable source maps in the development build so stack frames point to authored files.
  • Pause on uncaught exceptions and inspect the local values before the failing line runs.

Fix the cause, then retest

Check whether the value has the shape and timing the code expects. Add a guard only when the missing or invalid value is a real case the product should handle; a broad catch can hide the defect.

try {
  await saveChanges();
} catch (error) {
  console.error("Save failed", error);
  throw error;
}

After the smallest fix, repeat the original steps and run a test for the failure. A useful error report includes the browser, route, action, and sanitized trace, but never private tokens or customer data.