From 10aa5d2a220e08f8b5181f6beea55b1f570f9816 Mon Sep 17 00:00:00 2001 From: Ahmed Zamil Date: Tue, 17 Dec 2024 14:12:53 +0300 Subject: [PATCH] RecordParser --- src/Data/DataDeserializer.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Data/DataDeserializer.js b/src/Data/DataDeserializer.js index c03fb41..5898feb 100644 --- a/src/Data/DataDeserializer.js +++ b/src/Data/DataDeserializer.js @@ -172,9 +172,14 @@ export default class DataDeserializer { DataDeserializer.listParser(data, offset, length, connection, requestSequence).then((ar) => { let record; + if (template == null){ + reply.triggerError(new AsyncException(ErrorType.Management, ExceptionCode.TemplateNotFound, "Template not found for record.")); + return; + } + if (template.definedType != null) { record = new template.definedType(); - } else { + } else if (template != null) { record = new Record(); } @@ -189,23 +194,14 @@ export default class DataDeserializer { if (template != null) { initRecord(template); - } else { - if (connection == null) - throw Error("Can't parse record with no connection"); - + } else if (connection != null){ connection.getTemplate(classId).then((tmp) => { - if (tmp == null) - { - reply.triggerError(new AsyncException( - ErrorType.Management, - ExceptionCode.TemplateNotFound.index, - "Template not found for record.")); - } else { initRecord(tmp); - } - }).error((x) => reply.triggerError(x)); } + else { + initRecord(null); + } return reply; }