Skip to content

Error Types

APIErrorResponse

interface APIErrorResponse {
success: false;
code: string;
message: string;
errors?: Array<{
field: string;
code: string;
message: string;
}>;
}

ErrorCode

type ErrorCode =
| 'MISSING_API_KEY'
| 'INVALID_API_KEY'
| 'EXPIRED_API_KEY'
| 'REVOKED_API_KEY'
| 'INSUFFICIENT_SCOPE'
| 'IP_NOT_ALLOWED'
| 'RATE_LIMIT_EXCEEDED'
| 'DOCUMENT_NOT_FOUND'
| 'RESOURCE_NOT_FOUND'
| 'INVALID_REQUEST'
| 'INVALID_PARAMETER'
| 'EXPORT_LIMIT_EXCEEDED'
| 'EXPORT_SIZE_EXCEEDED'
| 'EXPORT_NO_FILES'
| 'INTERNAL_ERROR';

Error Classes

SonarSDKError

Base error class for all SDK errors.

class SonarSDKError extends Error {
code: ErrorCode | string;
status?: number;
requestId?: string;
details?: Record<string, unknown>;
errors?: Array<{ field: string; code: string; message: string }>;
timestamp: string;
toJSON(): object;
}

AuthenticationError

Thrown for authentication and authorization failures (HTTP 401/403). Extends SonarSDKError.

RateLimitError

Thrown when the API rate limit is exceeded (HTTP 429). Extends SonarSDKError.

class RateLimitError extends SonarSDKError {
retryAfter?: number;
}

DocumentNotFoundError

Thrown when a requested document does not exist (HTTP 404). Extends SonarSDKError.

class DocumentNotFoundError extends SonarSDKError {
documentId: string;
}

ValidationError

Thrown for client-side or server-side validation failures (HTTP 400). Extends SonarSDKError.


Complete Exports

Everything exported from @sonar/sdk:

// Main Client
export { SonarSDK } from './client';
// Configuration
export type { SonarSDKConfig } from './types/config';
// Document Types
export type {
Document, DocumentSignature, DocumentClassification,
SignatureType, ListDocumentsParams, ListDocumentsResponse,
ExportDocumentsParams, UploadDocumentParams, DocumentUploadSource,
DownloadResponse, DownloadUrlParams, DownloadUrlResponse,
DeleteDocumentResponse, BatchDeleteParams, BatchDeleteResponse,
ScopeAction, SignatureChainDocument, SignatureChain,
} from './types/documents';
// Scope Types & Constants
export { Scope } from './types/scopes';
export type {
AllowedScopesResponse, ScopeValue,
ScopeCategory, ScopeType, ScopeEntry,
} from './types/scopes';
// Error Types
export type { APIErrorResponse, ErrorCode } from './types/errors';
// Error Classes
export {
SonarSDKError, AuthenticationError, RateLimitError,
DocumentNotFoundError, ValidationError,
} from './utils/errors';