All files / client/src/types errorTypes.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25521x 521x 521x 521x 521x 521x 521x 521x                                  
export enum BackendErrorType {
  NETWORK_ERROR = "backendError.networkError",
  API_ERROR = "backendError.apiError",
  UNAUTHORIZED = "backendError.unauthorized",
  INVALID_REQUEST = "backendError.invalidRequest",
  SESSION_EXPIRED = "backendError.sessionExpired",
  LOGIN_DISABLED = "backendError.loginDisabled",
  UNKNOWN = "backendError.unknown",
}
 
// Errors are stored as translation keys and translated when rendered, so
// matching an error for removal keeps working across language switches. The
// message params exist only on the API error variant so that a plain
// { errorKey } payload always deep-equals the stored error when removing it
export type BackendError =
  | {
      errorKey: BackendErrorType.API_ERROR;
      method: string;
      url: string;
      errorReason: BackendErrorType;
    }
  | {
      errorKey: Exclude<BackendErrorType, BackendErrorType.API_ERROR>;
    };