neuwo-api
Version:
TypeScript/JavaScript SDK client for the Neuwo content classification API
135 lines • 4.35 kB
TypeScript
/**
* Error classes for Neuwo API.
*
* This module defines a hierarchy of error classes for handling various
* API error scenarios. All errors extend from the base NeuwoAPIError class.
*/
/**
* Base error class for all Neuwo API errors.
*
* All API-related errors inherit from this class, making it easy to catch
* any Neuwo API error with a single catch block.
*/
export declare class NeuwoAPIError extends Error {
/** HTTP status code if available */
statusCode?: number;
/**
* Creates a new NeuwoAPIError.
*
* @param message - Error message
* @param statusCode - HTTP status code
*/
constructor(message: string, statusCode?: number);
}
/**
* Error thrown when authentication fails (401).
*
* Indicates that the provided token is invalid or missing.
*/
export declare class AuthenticationError extends NeuwoAPIError {
constructor(message?: string);
}
/**
* Error thrown when token lacks necessary permissions (403).
*
* The token is valid but doesn't have permission to access the requested resource.
*/
export declare class ForbiddenError extends NeuwoAPIError {
constructor(message?: string);
}
/**
* Error thrown when requested resource is not found (404).
*
* The requested resource doesn't exist or hasn't been processed yet.
*/
export declare class NotFoundError extends NeuwoAPIError {
constructor(message?: string);
}
/**
* Error thrown when data is not yet available (URL not processed).
*
* This is a specialized NotFoundError (404) for EDGE endpoints, indicating
* the URL has been queued for processing and results will be available
* after crawling completes (typically 10-60 seconds).
*/
export declare class NoDataAvailableError extends NotFoundError {
constructor(message?: string);
}
/**
* Error thrown when request is malformed (400).
*
* The request syntax is invalid or missing required parameters.
*/
export declare class BadRequestError extends NeuwoAPIError {
constructor(message?: string);
}
/**
* Error thrown when request validation fails (422).
*
* The request is well-formed but contains invalid values or fails
* validation rules (e.g., empty content, invalid URL format).
*/
export declare class ValidationError extends NeuwoAPIError {
/** Structured validation error details from the API */
validationDetails?: unknown[];
/**
* Creates a new ValidationError.
*
* @param message - Error message
* @param validationDetails - Structured validation errors (typically an array of field-level errors)
*/
constructor(message?: string, validationDetails?: unknown[]);
}
/**
* Error thrown when rate limit is exceeded (429).
*
* Too many requests have been made in a given time period.
* Wait before retrying.
*/
export declare class RateLimitError extends NeuwoAPIError {
/** Number of seconds to wait before retrying (from Retry-After header) */
retryAfter?: number;
/**
* Creates a new RateLimitError.
*
* @param message - Error message
* @param retryAfter - Number of seconds to wait before retrying
*/
constructor(message?: string, retryAfter?: number);
}
/**
* Error thrown when server encounters an error (5xx).
*
* The server encountered an unexpected condition that prevented it
* from fulfilling the request.
*/
export declare class ServerError extends NeuwoAPIError {
constructor(message?: string, statusCode?: number);
}
/**
* Error thrown when network communication fails.
*
* Indicates a network-level error such as timeout, connection refused,
* or DNS resolution failure.
*/
export declare class NetworkError extends NeuwoAPIError {
/** Original error that caused the network failure */
cause?: Error;
constructor(message?: string, cause?: Error);
}
/**
* Error thrown when content tagging could not be created (EDGE API).
*
* This is a permanent error indicating that the content at the URL
* could not be analysed. This is different from NoDataAvailableError
* which is temporary.
*/
export declare class ContentNotAvailableError extends NeuwoAPIError {
/** The URL that could not be processed */
url?: string;
constructor(message?: string, url?: string);
}
export declare class ValueError extends Error {
constructor(message: string);
}
//# sourceMappingURL=errors.d.ts.map