Polyweave

@polyweave/errors (1.0.2)

Published 2026-07-10 15:15:10 +00:00 by Dvorak

Installation

@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/
npm install @polyweave/errors@1.0.2
"@polyweave/errors": "1.0.2"

About this package

errors

Standardized error codes and helpers for Polyweave.

Synopsis

import { ErrorCode, normalizeErrorCode, mapHttpStatusToErrorCode } from '@polyweave/errors';

const code = normalizeErrorCode('RATE_LIMITED');
console.log(code === ErrorCode.RATE_LIMIT_EXCEEDED); // true

Install

npm install @polyweave/errors

API

ErrorCode

Re-exported from @polyweave/core. Enum of standard Polyweave error codes including RATE_LIMIT_EXCEEDED, QUEUE_TIMEOUT, INVALID_INPUT, AUTHENTICATION_ERROR, AUTHORIZATION_ERROR, SERVICE_UNAVAILABLE, PROVIDER_ERROR, PROTOCOL_ERROR, ADAPTER_ERROR, and more.

normalizeErrorCode(code)

Accepts a raw error code string, an alias, or an ErrorCode value and returns the canonical ErrorCode. Returns ErrorCode.ADAPTER_ERROR for unknown or falsy input.

normalizeRateLimit(rateLimit)

Accepts a rate limit object from a provider response. Strips null/undefined fields and returns the cleaned object, or null if empty.

parseRetryAfterSeconds(value)

Accepts a string or number (e.g. HTTP Retry-After header) and returns the delay in seconds as a number. Supports date strings and numeric values.

buildErrorMetadata(options)

Builds a metadata object for PolyweaveError. Accepts { provider, statusCode, errorType, errorCode, originalFrameType, rateLimit, retryAfterSeconds, requestId, originalError, providerError, retryable }.

mapHttpStatusToErrorCode(status)

Maps an HTTP status code to the corresponding ErrorCode. Handles 400, 401, 403, 404, 408, 409, 422, 429, 500, 502, 503, 504, 529.

isRetryableErrorCode(code)

Returns true if the given error code represents a transient failure suitable for automatic retry.

Tests

npm test

Requirements

Node.js 18 or later. ESM only.

License

MIT

Dependencies

Development Dependencies

ID Version
@rigor/core *

Peer Dependencies

ID Version
@polyweave/core ^1.0.0

Keywords

polyweave errors error-codes mapping
Details
npm
2026-07-10 15:15:10 +00:00
48
John Dvorak
SEE LICENSE IN LICENSE
2.4 KiB
Assets (1)
Versions (7) View all
1.0.8 2026-07-20
1.0.9 2026-07-11
1.0.6 2026-07-11
1.0.5 2026-07-10
1.0.4 2026-07-10