Awesome Reviewers

Reviewer · Error Handling

User-facing error recovery

When an async operation fails, never leave the UI silently stuck or in an inconsistent state. First, always surface failures to the user: if a deep-linked resource can't be found or the user lacks permission, show a toast or message instead of just dropping the state (e.g. landing on a table with no explanation); if a dynamic import or data fetch fails,...

Instruction

When an async operation fails, never leave the UI silently stuck or in an inconsistent state. First, always surface failures to the user: if a deep-linked resource can’t be found or the user lacks permission, show a toast or message instead of just dropping the state (e.g. landing on a table with no explanation); if a dynamic import or data fetch fails, read the error from the async hook and render it instead of an infinite spinner.

Second, distinguish error types to pick the right recovery strategy rather than applying one blanket behavior:

  • For “not found” errors, fall back to a degraded-but-usable mode (e.g. show raw query DSL when a data view is missing) instead of breaking the editor.
  • For transient errors (network/permission issues, in-flight refetches), prefer preserving the last known-good value rather than clearing it, since the underlying data is likely still valid; pair this with an error toast so the user knows the fetch failed.
  • For conflict errors (e.g. HTTP 409 on save), reload the latest server state into the store, keep the user’s in-progress dialog open, and show a clear message (“this was changed elsewhere, your change wasn’t saved, the latest version is now loaded”) so the next save applies on top of fresh data instead of silently overwriting or repeatedly failing.
  • When an upstream fetch failed, avoid destructive writes that would reset other settings to defaults — skip the write (or disable the action) until the data is successfully loaded.

Example pattern:

try {
  data = await fetchResource(id);
} catch (e) {
  if (signal.aborted) return;
  if (e instanceof NotFoundError) {
    showFallbackMode(); // degrade gracefully
  } else {
    showErrorToast(); // transient/unknown error, keep existing value
  }
  return;
}

Applying this consistently ensures users get clear feedback on failures and the app recovers in a way that matches the actual cause of the error, rather than guessing or failing silently.