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.
Parameters
statusCoderequirednumberHTTP status code.
messagerequiredstringError message.
codeoptionalstringMachine-readable error code.
detailsoptionalRecord<string, unknown>Additional error details.
requestIdoptionalstringRequest ID for tracing.
createErrorFromStatus(statusCode: number, message: string, code?: string, details?: Record<string, unknown>, requestId?: string): SdkApiErrorimport { 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');SdkApiErrorerrors.isSdkApiError()
Type guard for the base SdkApiError class.
Parameters
errorrequiredunknownValue to check.
isSdkApiError(error: unknown): error is SdkApiErrorimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await errors.isSdkApiError('example-value');booleanerrors.isValidationError()
Type guard for ValidationError (400 Bad Request).
Parameters
errorrequiredunknownValue to check.
isValidationError(error: unknown): error is ValidationErrorimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await errors.isValidationError('example-value');booleanerrors.isNotFoundError()
Type guard for NotFoundError (404 Not Found).
Parameters
errorrequiredunknownValue to check.
isNotFoundError(error: unknown): error is NotFoundErrorimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await errors.isNotFoundError('example-value');booleanerrors.isRateLimitError()
Type guard for RateLimitError (429 Too Many Requests). The error includes a retryAfter field with seconds to wait.
Parameters
errorrequiredunknownValue to check.
isRateLimitError(error: unknown): error is RateLimitErrorimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await errors.isRateLimitError('example-value');booleanerrors.isNetworkError()
Type guard for NetworkError (connection failure, DNS resolution failure).
Parameters
errorrequiredunknownValue to check.
isNetworkError(error: unknown): error is NetworkErrorimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await errors.isNetworkError('example-value');booleanerrors.isTimeoutError()
Type guard for TimeoutError (request exceeded timeout).
Parameters
errorrequiredunknownValue to check.
isTimeoutError(error: unknown): error is TimeoutErrorimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await errors.isTimeoutError('example-value');booleanerrors.isRedirectError()
Type guard for RedirectError — thrown when a cross-origin redirect is blocked (redirect hardening, 0.14.0).
Parameters
erequiredunknownValue to test.
isRedirectError(e): e is RedirectErrorimport { HttpClient } from '@uluops/sdk-core';
const client = new HttpClient({
apiKey: 'ulr_your-api-key',
});
const result = await errors.isRedirectError('example-value');e is RedirectError