Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xranx OpenContext Error Classification

From Leeroopedia
Knowledge Sources
Domains Error_Handling
Last Updated 2026-10-24 00:00 GMT

Overview

Error classification utility that categorizes API errors into typed buckets (not found, server, network, unknown) to avoid scattered string matching throughout the codebase.

Description

The errors.js module in src/ui/src/utils/ exports an ErrorType enum (NOT_FOUND, SERVER_ERROR, NETWORK_ERROR, UNKNOWN), a classifyError function that inspects HTTP status codes and message text to determine the error type, isNotFoundError (true for 404 and 500 errors since the backend may throw 500 on missing resources), and isTransientError for recoverable network errors.

Usage

Import these functions in hooks and components that handle API errors, especially useDataIntegrity and useFolderCache.

Code Reference

Source Location

Signature

export const ErrorType = { NOT_FOUND, SERVER_ERROR, NETWORK_ERROR, UNKNOWN }
export function classifyError(err) // → ErrorType
export function isNotFoundError(err) // → boolean
export function isTransientError(err) // → boolean

Import

import { classifyError, isNotFoundError, ErrorType } from './utils/errors';

I/O Contract

Inputs

Name Type Required Description
err string|any Yes Error object with message/status

Outputs

Name Type Description
classifyError string ErrorType enum value
isNotFoundError boolean True if NOT_FOUND or SERVER_ERROR
isTransientError boolean True if NETWORK_ERROR

Usage Examples

Classifying Errors

import { classifyError, isNotFoundError, ErrorType } from './utils/errors';

try {
  await api.listDocs(folderPath);
} catch (err) {
  if (isNotFoundError(err)) {
    // Folder was deleted, clean up cache
    removeStaleFolder(folderPath);
  } else if (classifyError(err) === ErrorType.NETWORK_ERROR) {
    // Retry later
    scheduleRetry();
  }
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment