// SPDX-License-Identifier: Apache-2.0
export var ErrorCode;
(function (ErrorCode) {
    // Error codes for Input Data (Prefix: 1XXXX)
    ErrorCode["AccountIdInValid"] = "10001";
    ErrorCode["AccountIdNotExists"] = "10026";
    ErrorCode["ContractKeyInvalid"] = "10006";
    ErrorCode["EmptyValue"] = "10017";
    ErrorCode["InvalidAmount"] = "10008";
    ErrorCode["InvalidBase64"] = "10011";
    ErrorCode["InvalidBytes"] = "10007";
    ErrorCode["InvalidBytes3"] = "10003";
    ErrorCode["InvalidBytes32"] = "10002";
    ErrorCode["InvalidContractId"] = "10014";
    ErrorCode["InvalidDividendType"] = "10028";
    ErrorCode["InvalidEvmAddress"] = "10023";
    ErrorCode["InvalidIdFormatHedera"] = "10009";
    ErrorCode["InvalidIdFormatHederaIdOrEvmAddress"] = "10010";
    ErrorCode["InvalidLength"] = "10016";
    ErrorCode["InvalidRange"] = "10018";
    ErrorCode["InvalidRegulationSubType"] = "10030";
    ErrorCode["InvalidRegulationSubTypeForType"] = "10031";
    ErrorCode["InvalidRegulationType"] = "10029";
    ErrorCode["InvalidRequest"] = "10024";
    ErrorCode["InvalidRole"] = "10019";
    ErrorCode["InvalidSecurityType"] = "10020";
    ErrorCode["InvalidType"] = "10015";
    ErrorCode["InvalidValue"] = "10021";
    ErrorCode["PublicKeyInvalid"] = "10004";
    ErrorCode["ValidationChecks"] = "10022";
    ErrorCode["InvalidClearingOperationType"] = "10032";
    ErrorCode["InvalidClearingOperationTypeNumber"] = "10033";
    ErrorCode["InvalidVcFormat"] = "10034";
    ErrorCode["InvalidVcDates"] = "10036";
    ErrorCode["InvalidTimeUnits"] = "10037";
    ErrorCode["InvalidInterestRateType"] = "10038";
    ErrorCode["InvalidRateStatus"] = "10039";
    ErrorCode["InvalidNegativeRate"] = "10040";
    // Error codes for Logic Errors (Prefix: 2XXXX)
    ErrorCode["AccountAlreadyInControlList"] = "20013";
    ErrorCode["AccountIsAlreadyAnIssuer"] = "20020";
    ErrorCode["AccountFreeze"] = "20008";
    ErrorCode["AccountInBlackList"] = "20011";
    ErrorCode["AccountNotAssociatedToSecurity"] = "20001";
    ErrorCode["AccountNotInControlList"] = "20015";
    ErrorCode["AccountNotInWhiteList"] = "20012";
    ErrorCode["InsufficientBalance"] = "20009";
    ErrorCode["InsufficientFunds"] = "20005";
    ErrorCode["InsufficientHoldBalance"] = "20019";
    ErrorCode["MaxSupplyReached"] = "20002";
    ErrorCode["NounceAlreadyUsed"] = "20016";
    ErrorCode["OperationNotAllowed"] = "20004";
    ErrorCode["PartitionsProtected"] = "20017";
    ErrorCode["PartitionsUnprotected"] = "20018";
    ErrorCode["RoleNotAssigned"] = "20003";
    ErrorCode["SecurityPaused"] = "20010";
    ErrorCode["SecurityUnPaused"] = "20014";
    ErrorCode["UnlistedKycIssuer"] = "20021";
    ErrorCode["InvalidVcHolder"] = "20022";
    ErrorCode["InvalidVc"] = "20023";
    ErrorCode["ClearingActivated"] = "20024";
    ErrorCode["ClearingDeactivated"] = "20025";
    ErrorCode["AccountNotKycd"] = "20026";
    ErrorCode["AccountIsNotOperator"] = "20027";
    ErrorCode["InsufficientAllowance"] = "20028";
    ErrorCode["InvalidPartition"] = "20029";
    ErrorCode["InvalidFromAccount"] = "20030";
    ErrorCode["InvalidDestinationAccount"] = "20031";
    ErrorCode["MaxSupplyByPartitionReached"] = "20032";
    ErrorCode["NotAllowedInMultiPartition"] = "20033";
    ErrorCode["OnlyDefaultPartitionAllowed"] = "20034";
    ErrorCode["NotIssuable"] = "20035";
    ErrorCode["InvalidSupply"] = "20036";
    ErrorCode["AddressRecovered"] = "20037";
    ErrorCode["ZeroAddressNotAllowed"] = "20038";
    ErrorCode["AccountBlocked"] = "20039";
    ErrorCode["ComplianceNotAllowed"] = "20040";
    ErrorCode["InvalidKycStatus"] = "20041";
    ErrorCode["WalletRecovered"] = "20042";
    ErrorCode["AddressNotVerified"] = "20043";
    ErrorCode["AccountIsProceedRecipient"] = "20044";
    ErrorCode["AccountIsNotProceedRecipient"] = "20045";
    // Error codes for System Errors (Prefix: 3XXXX)
    ErrorCode["ContractNotFound"] = "30002";
    ErrorCode["InvalidResponse"] = "30005";
    ErrorCode["NotFound"] = "30006";
    ErrorCode["ReceiptNotReceived"] = "30001";
    ErrorCode["RuntimeError"] = "30004";
    ErrorCode["Unexpected"] = "30003";
    ErrorCode["TransactionNotFound"] = "30007";
    ErrorCode["TransactionResultNotFound"] = "30008";
    ErrorCode["BalanceNotFound"] = "30009";
    ErrorCode["ErrorRetrievingEvmAddress"] = "30010";
    ErrorCode["PublickKeyNotFound"] = "30011";
    ErrorCode["UnsupportedNetwork"] = "30012";
    ErrorCode["NotInitialized"] = "30013";
    ErrorCode["AccountNotSet"] = "30014";
    ErrorCode["NoSettings"] = "30015";
    ErrorCode["NoSigners"] = "30016";
    ErrorCode["AccountNotRetrievedFromSigners"] = "30017";
    ErrorCode["AccountNotFound"] = "30018";
    ErrorCode["ConsensusNodesNotSet"] = "30019";
    ErrorCode["SignatureNotFound"] = "30020";
    ErrorCode["ErrorDecodingVc"] = "30021";
    ErrorCode["EmptyResponse"] = "30022";
    ErrorCode["WalletNotSupported"] = "30023";
    ErrorCode["UncaughtCommandError"] = "30024";
    ErrorCode["UncaughtQueryError"] = "30025";
    // Error codes for Provider Errors (Prefix: 4XXXX)
    ErrorCode["DeploymentError"] = "40006";
    ErrorCode["InitializationError"] = "40001";
    ErrorCode["PairingError"] = "40002";
    ErrorCode["PairingRejected"] = "40008";
    ErrorCode["ProviderError"] = "40007";
    ErrorCode["SigningError"] = "40004";
    ErrorCode["TransactionCheck"] = "40003";
    ErrorCode["TransactionError"] = "40005";
})(ErrorCode || (ErrorCode = {}));
export var ErrorCategory;
(function (ErrorCategory) {
    ErrorCategory["InputData"] = "1";
    ErrorCategory["Logic"] = "2";
    ErrorCategory["System"] = "3";
    ErrorCategory["Provider"] = "4";
})(ErrorCategory || (ErrorCategory = {}));
export function getErrorCategory(errorCode) {
    switch (true) {
        case errorCode.startsWith(ErrorCategory.InputData):
            return ErrorCategory.InputData;
        case errorCode.startsWith(ErrorCategory.Logic):
            return ErrorCategory.Logic;
        default:
            return ErrorCategory.System;
    }
}
export default class BaseError extends Error {
    message;
    errorCode;
    errorCategory;
    /**
     * Generic Error Constructor
     */
    constructor(code, msg) {
        super(msg);
        this.message = msg;
        this.errorCode = code;
        this.errorCategory = getErrorCategory(code);
    }
    toString(stack = false) {
        return `${this.errorCode} - ${stack ? this.stack : this.message}`;
    }
}
