import { CodeError } from '@iotize/common/error';
import { listEnumValues } from '@iotize/common/utility';
export class TlvJsonCompressorError extends CodeError {
    static maxDataLengthReach(length, maxLength) {
        return new TlvJsonCompressorError(`Cannot write ${length} bytes. Maximum field length is ${maxLength} bytes.`, TlvJsonCompressorError.Code.MaxDataLengthReach);
    }
    static unknownFieldName(fieldName) {
        return new TlvJsonCompressorError(`Cannot find definition for field name "${fieldName}"`, TlvJsonCompressorError.Code.UnknownFieldName);
    }
    static unknownFieldCode(code) {
        return new TlvJsonCompressorError(`Cannot find definition for code "${code}"`, TlvJsonCompressorError.Code.UnknownFieldCode);
    }
    static unexpectedCharacter(msg) {
        return new TlvJsonCompressorError(msg, TlvJsonCompressorError.Code.UnexpectedCharacter);
    }
    static invalidEnumKey(key, mapping) {
        return new TlvJsonCompressorError(`Invalid enum key "${key}". Authorized keys are ${listEnumValues(mapping)
            .map((key) => `${key}: ${mapping[key]}`)
            .join(', ')}`, TlvJsonCompressorError.Code.InvalidEnumKey);
    }
}
(function (TlvJsonCompressorError) {
    let Code;
    (function (Code) {
        Code["UnknownFieldCode"] = "TlvJsonCompressorErrorUnknownFieldCode";
        Code["UnknownFieldName"] = "TlvJsonCompressorErrorUnknownFieldName";
        Code["UnexpectedCharacter"] = "TlvJsonCompressorErrorUnexpectedCharacter";
        Code["MaxDataLengthReach"] = "TlvJsonCompressorErrorMaxDataLengthReach";
        Code["InvalidEnumKey"] = "TlvJsonCompressorErrorInvalidEnumKey";
    })(Code = TlvJsonCompressorError.Code || (TlvJsonCompressorError.Code = {}));
})(TlvJsonCompressorError || (TlvJsonCompressorError = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vZXh0cmEvZGJpb3Qvc3JjL2xpYi9qc29uLWNvbXByZXNzb3IvZXJyb3JzLnRzIl0sIm5h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