Registry↗Dashboard↗

Errors

Typed error classes for every HTTP status code and type guard functions for error discrimination in catch blocks.

9 methods

errors.createErrorFromStatus()

Create the appropriate error subclass from an HTTP status code. Maps 400→ValidationError, 401→UnauthorizedError, etc.

statusCoderequirednumber

HTTP status code.

messagerequiredstring

Error message.

codeoptionalstring

Machine-readable error code.

detailsoptionalRecord<string, unknown>

Additional error details.

requestIdoptionalstring

Request ID for tracing.

createErrorFromStatus(statusCode: number, message: string, code?: string, details?: Record<string, unknown>, requestId?: string): SdkApiError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.createErrorFromStatus(85.5, 'Resolved in latest commit');
Response Type
SdkApiError

errors.isSdkApiError()

Type guard for the base SdkApiError class.

errorrequiredunknown

Value to check.

isSdkApiError(error: unknown): error is SdkApiError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isSdkApiError('example-value');
Response Type
boolean

errors.isValidationError()

Type guard for ValidationError (400 Bad Request).

errorrequiredunknown

Value to check.

isValidationError(error: unknown): error is ValidationError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isValidationError('example-value');
Response Type
boolean

errors.isNotFoundError()

Type guard for NotFoundError (404 Not Found).

errorrequiredunknown

Value to check.

isNotFoundError(error: unknown): error is NotFoundError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isNotFoundError('example-value');
Response Type
boolean

errors.isRateLimitError()

Type guard for RateLimitError (429 Too Many Requests). The error includes a retryAfter field with seconds to wait.

errorrequiredunknown

Value to check.

isRateLimitError(error: unknown): error is RateLimitError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isRateLimitError('example-value');
Response Type
boolean

errors.isUnauthorizedError()

Type guard for UnauthorizedError (401 Unauthorized).

errorrequiredunknown

Value to check.

isUnauthorizedError(error: unknown): error is UnauthorizedError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isUnauthorizedError('example-value');
Response Type
boolean

errors.isNetworkError()

Type guard for NetworkError (connection failure, DNS resolution failure).

errorrequiredunknown

Value to check.

isNetworkError(error: unknown): error is NetworkError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isNetworkError('example-value');
Response Type
boolean

errors.isTimeoutError()

Type guard for TimeoutError (request exceeded timeout).

errorrequiredunknown

Value to check.

isTimeoutError(error: unknown): error is TimeoutError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isTimeoutError('example-value');
Response Type
boolean

errors.isRedirectError()

Type guard for RedirectError — thrown when a cross-origin redirect is blocked (redirect hardening, 0.14.0).

erequiredunknown

Value to test.

isRedirectError(e): e is RedirectError
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await errors.isRedirectError('example-value');
Response Type
e is RedirectError