Implementation:0xranx OpenContext Error Classification
| 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
- Repository: 0xranx_OpenContext
- File: src/ui/src/utils/errors.js
- Lines: 1-72
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();
}
}