Awesome Reviewers

Reviewer · Error Handling

Selective, consistent error handling

Avoid broad catch blocks that silently swallow every error. Always parse the error first (using the shared `api.parseError` utility) and only handle the specific, expected case—such as a 404 meaning "no data exists yet." Any other error (e.g., a 403 permission failure) must be rethrown so it propagates to the UI's error-handling template/component instead...

Instruction

Avoid broad catch blocks that silently swallow every error. Always parse the error first (using the shared api.parseError utility) and only handle the specific, expected case—such as a 404 meaning “no data exists yet.” Any other error (e.g., a 403 permission failure) must be rethrown so it propagates to the UI’s error-handling template/component instead of being masked as an empty state.

When rethrowing, preserve a consistent error shape (e.g., always use status, not a mix of status/httpStatus) so downstream error components can render it correctly. Prefer reusing shared parsing/formatting logic (like api.parseError) over duplicating instanceof checks or ad hoc string/error branching—this keeps error messages consistent and reduces bugs when consolidating error UI (e.g., Page::Error).

Example:

async fetchSnapshots() {
  try {
    const { keys } = await this.api.sys.systemListStorageRaftSnapshotLoad(...);
    return keys as string[];
  } catch (e) {
    const error = await this.api.parseError(e);
    if (error.status === 404) {
      return []; // expected case: no snapshots yet
    }
    // rethrow with consistent shape so it surfaces in the error template
    throw { status: error.status, ...error };
  }
}

Apply this pattern consistently across routes, services, and components: inspect before swallowing, rethrow unexpected failures, and standardize the error object shape and message formatting so failures are never hidden from the user and always render correctly.</description>