/** * March Agent SDK - Custom Errors * Port of Python march_agent/exceptions.py */ /** * Base error class for March Agent SDK */ export class MarchAgentError extends Error { constructor(message: string) { super(message) this.name = 'MarchAgentError' Error.captureStackTrace?.(this, this.constructor) } } /** * Error during agent registration with AI Inventory */ export class RegistrationError extends MarchAgentError { constructor(message: string) { super(message) this.name = 'RegistrationError' } } /** * Error during Kafka operations (produce/consume) */ export class KafkaError extends MarchAgentError { constructor(message: string) { super(message) this.name = 'KafkaError' } } /** * Error in SDK configuration */ export class ConfigurationError extends MarchAgentError { constructor(message: string) { super(message) this.name = 'ConfigurationError' } } /** * Error from API calls to backend services */ export class APIException extends MarchAgentError { statusCode?: number constructor(message: string, statusCode?: number) { super(message) this.name = 'APIException' this.statusCode = statusCode } } /** * Error during heartbeat operations */ export class HeartbeatError extends MarchAgentError { constructor(message: string) { super(message) this.name = 'HeartbeatError' } } /** * Error during gRPC connection/communication */ export class GatewayError extends MarchAgentError { constructor(message: string) { super(message) this.name = 'GatewayError' } } /** * Error during reconnection attempts */ export class ReconnectionError extends MarchAgentError { /** Number of attempts made before giving up */ attempts: number /** The last error that occurred during reconnection */ lastError?: Error constructor(message: string, attempts: number, lastError?: Error) { super(message) this.name = 'ReconnectionError' this.attempts = attempts this.lastError = lastError } }