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 Clientexport { SonarSDK } from './client';
// Configurationexport type { SonarSDKConfig } from './types/config';
// Document Typesexport type { Document, DocumentSignature, DocumentClassification, SignatureType, ListDocumentsParams, ListDocumentsResponse, ExportDocumentsParams, UploadDocumentParams, DocumentUploadSource, DownloadResponse, DownloadUrlParams, DownloadUrlResponse, DeleteDocumentResponse, BatchDeleteParams, BatchDeleteResponse, ScopeAction, SignatureChainDocument, SignatureChain,} from './types/documents';
// Scope Types & Constantsexport { Scope } from './types/scopes';export type { AllowedScopesResponse, ScopeValue, ScopeCategory, ScopeType, ScopeEntry,} from './types/scopes';
// Error Typesexport type { APIErrorResponse, ErrorCode } from './types/errors';
// Error Classesexport { SonarSDKError, AuthenticationError, RateLimitError, DocumentNotFoundError, ValidationError,} from './utils/errors';