"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AllProvidersUnavailableError = exports.AdapterError = exports.AdapterErrorCode = void 0;
var AdapterErrorCode;
(function (AdapterErrorCode) {
    AdapterErrorCode["INVALID_REQUEST"] = "INVALID_REQUEST";
    AdapterErrorCode["NOT_FOUND"] = "NOT_FOUND";
    AdapterErrorCode["AUTH"] = "AUTH";
    AdapterErrorCode["RATE_LIMIT"] = "RATE_LIMIT";
    AdapterErrorCode["TIMEOUT"] = "TIMEOUT";
    AdapterErrorCode["UPSTREAM"] = "UPSTREAM";
})(AdapterErrorCode || (exports.AdapterErrorCode = AdapterErrorCode = {}));
/**
 * Single error class for all adapter failures.
 * Code determines semantics; affectsHealth is derived from the code.
 */
class AdapterError extends Error {
    constructor(providerName, code, detail) {
        super(`${providerName}: ${detail || code}`);
        this.providerName = providerName;
        this.code = code;
        this.name = 'AdapterError';
        this.affectsHealth = code !== AdapterErrorCode.INVALID_REQUEST && code !== AdapterErrorCode.NOT_FOUND;
    }
}
exports.AdapterError = AdapterError;
/**
 * Thrown when all providers are unavailable or returned errors.
 * Route handlers should map this to HTTP 503.
 */
class AllProvidersUnavailableError extends Error {
    constructor(operation, chain, network) {
        super(`All indexed API providers unavailable for ${operation} on ${chain}:${network}`);
        this.name = 'AllProvidersUnavailableError';
    }
}
exports.AllProvidersUnavailableError = AllProvidersUnavailableError;
//# sourceMappingURL=errors.js.map