import { CodeError } from '@iotize/common/error';
export class TapDataError extends CodeError {
    constructor(msg, code, cause) {
        super(msg, code);
        this.cause = cause;
    }
    static unexpectedEncodedValueError(variable, rawData, err) {
        return new TapDataError(`An error occured while encoding value for variable ${variable.id}. ${err.message}`, TapDataError.Code.UnexpectedEncodedValueError);
    }
    static unexpectedVariableDataRead(variable, rawData, err) {
        return new TapDataError(`An error occured while decoding value for variable ${variable.id}. ${err.message}`, TapDataError.Code.UnexpectedVariableData);
    }
    static bundleNotFound(key) {
        return new TapDataError(`Bundle with identifier "${key.toString()}" is not registered`, TapDataError.Code.BundleNotFound);
    }
    static variableNotFound(key) {
        return new TapDataError(`Variable with identifier "${key.toString()}" is not registered`, TapDataError.Code.VariableNotFound);
    }
    static bundleNotConfigured(config, err) {
        return new TapDataError(`Bundle with id "${config.id}" does not exist on this Tap. You should reconfigure your Tap to add this bundle.`, TapDataError.Code.BundleNotConfigured, err);
    }
    static variableNotConfigured(config, err) {
        return new TapDataError(`Variable with id "${config.id}" does not exist on this Tap. You should reconfigure your Tap to add this variable.`, TapDataError.Code.VariableNotConfigured, err);
    }
}
(function (TapDataError) {
    let Code;
    (function (Code) {
        Code["UnexpectedVariableData"] = "TapDataErrorUnexpectedVariableData";
        Code["UnexpectedEncodedValueError"] = "TapDataErrorUnexpectedEncodedValueError";
        Code["BundleNotFound"] = "TapDataErrorBundleNotFound";
        Code["VariableNotFound"] = "TapDataErrorVariableNotFound";
        Code["BundleNotConfigured"] = "TapDataErrorBundleNotConfigured";
        Code["VariableNotConfigured"] = "TapDataErrorVariableNotConfigured";
    })(Code = TapDataError.Code || (TapDataError.Code = {}));
})(TapDataError || (TapDataError = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwLWRhdGEtZXJyb3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9kYXRhL3NyYy9saWIvdGFwLWRhdGEtZXJyb3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