{"version":3,"file":"index.cjs","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":["/**\n * Custom error classes for the Eclesia indexer\n * These provide better context and error tracking throughout the application\n */\n\n/**\n * Base error class for all indexer errors\n * Extends Error with additional context fields\n */\nexport class IndexerError extends Error {\n  /** Error code for programmatic error handling */\n  public readonly code: string;\n\n  /** Additional context data for debugging */\n  public readonly context?: Record<string, unknown>;\n\n  constructor(message: string, code: string = \"INDEXER_ERROR\", context?: Record<string, unknown>) {\n    super(message);\n    this.name = this.constructor.name;\n    this.code = code;\n    this.context = context;\n\n    // Maintains proper stack trace for where error was thrown\n    if (Error.captureStackTrace) {\n      Error.captureStackTrace(this, this.constructor);\n    }\n  }\n}\n\n/**\n * Configuration-related errors\n * Thrown when indexer configuration is invalid or missing\n */\nexport class ConfigurationError extends IndexerError {\n  constructor(message: string, context?: Record<string, unknown>) {\n    super(message, \"CONFIGURATION_ERROR\", context);\n  }\n}\n\n/**\n * RPC connection and communication errors\n * Thrown when RPC calls fail or connections are lost\n */\nexport class RPCError extends IndexerError {\n  /** The RPC endpoint that failed */\n  public readonly endpoint?: string;\n\n  /** The height being queried when error occurred */\n  public readonly height?: number;\n\n  constructor(\n    message: string,\n    endpoint?: string,\n    height?: number,\n    context?: Record<string, unknown>,\n  ) {\n    super(message, \"RPC_ERROR\", {\n      ...context,\n      endpoint,\n      height,\n    });\n    this.endpoint = endpoint;\n    this.height = height;\n  }\n}\n\n/**\n * Database operation errors\n * Thrown when database queries or transactions fail\n */\nexport class DatabaseError extends IndexerError {\n  /** The SQL query that failed */\n  public readonly query?: string;\n\n  /** The operation that failed (e.g., \"BEGIN\", \"COMMIT\", \"ROLLBACK\") */\n  public readonly operation?: string;\n\n  constructor(message: string, operation?: string, query?: string, context?: Record<string, unknown>) {\n    super(message, \"DATABASE_ERROR\", {\n      ...context,\n      operation,\n      query,\n    });\n    this.operation = operation;\n    this.query = query;\n  }\n}\n\n/**\n * Block processing errors\n * Thrown when block data is invalid or processing fails\n */\nexport class BlockProcessingError extends IndexerError {\n  /** The height of the block that failed to process */\n  public readonly height: number;\n\n  constructor(message: string, height: number, context?: Record<string, unknown>) {\n    super(message, \"BLOCK_PROCESSING_ERROR\", {\n      ...context,\n      height,\n    });\n    this.height = height;\n  }\n}\n\n/**\n * Module initialization errors\n * Thrown when indexing modules fail to initialize\n */\nexport class ModuleError extends IndexerError {\n  /** The name of the module that failed */\n  public readonly moduleName: string;\n\n  constructor(message: string, moduleName: string, context?: Record<string, unknown>) {\n    super(message, \"MODULE_ERROR\", {\n      ...context,\n      moduleName,\n    });\n    this.moduleName = moduleName;\n  }\n}\n\n/**\n * Genesis processing errors\n * Thrown when genesis file parsing or processing fails\n */\nexport class GenesisError extends IndexerError {\n  /** Path to the genesis file */\n  public readonly genesisPath?: string;\n\n  constructor(message: string, genesisPath?: string, context?: Record<string, unknown>) {\n    super(message, \"GENESIS_ERROR\", {\n      ...context,\n      genesisPath,\n    });\n    this.genesisPath = genesisPath;\n  }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,eAAb,cAAkC,MAAM;;CAEtC,AAAgB;;CAGhB,AAAgB;CAEhB,YAAY,SAAiB,OAAe,iBAAiB,SAAmC;AAC9F,QAAM,QAAQ;AACd,OAAK,OAAO,KAAK,YAAY;AAC7B,OAAK,OAAO;AACZ,OAAK,UAAU;AAGf,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;;AASrD,IAAa,qBAAb,cAAwC,aAAa;CACnD,YAAY,SAAiB,SAAmC;AAC9D,QAAM,SAAS,uBAAuB,QAAQ;;;;;;;AAQlD,IAAa,WAAb,cAA8B,aAAa;;CAEzC,AAAgB;;CAGhB,AAAgB;CAEhB,YACE,SACA,UACA,QACA,SACA;AACA,QAAM,SAAS,aAAa;GAC1B,GAAG;GACH;GACA;GACD,CAAC;AACF,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;;AAQlB,IAAa,gBAAb,cAAmC,aAAa;;CAE9C,AAAg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