From 43eeb1e501f288f6c893865daf589e90a7f7c010 Mon Sep 17 00:00:00 2001 From: Nilesh Pant <58652823+NileshPant1999@users.noreply.github.com> Date: Fri, 16 Jun 2023 11:14:58 +0530 Subject: [PATCH] use keys we store in destination attribute db and remove loggers (#120) --- netsuitesdk/errors/parser.py | 12 ++++-------- netsuitesdk/internal/client.py | 11 +++++++---- setup.py | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/netsuitesdk/errors/parser.py b/netsuitesdk/errors/parser.py index 55d1f33..59d0d30 100644 --- a/netsuitesdk/errors/parser.py +++ b/netsuitesdk/errors/parser.py @@ -14,28 +14,24 @@ def get_entity_values(self, error_dict): if object_1 and object_2: if entity_keys[0] == 'customer' and entity_keys[1] == 'employee': - object_1 = object_1['entityId'] - object_2 = object_2['email'] if object_2['email'] else object_2['firstName'] + " " + object_2['lastName'] - return object_1, object_2 + return object_1['entityId'], object_2['entityId'] if entity_keys[1] == 'employee': - object_2 = object_2['email'] if object_2['email'] else object_2['firstName'] + " " + object_2['lastName'] - return object_1['name'], object_2 + return object_1['name'], object_2['entityId'] if entity_keys[0] == 'account': object_1 = object_1['acctName'] return object_1, object_2['name'] if entity_keys[0] == 'vendor': - object_1 = object_1['companyName'] if object_1['companyName'] else object_1['entityId'] - return object_1, object_2['name'] + return object_1['entityId'], object_2['name'] + return object_1['name'], object_2['name'] def export_error_parser(self, error_dict, message): parsed_message = message - print('dsdf', list(error_dict)) if list(error_dict) in list_of_dicts: object_1, object_2 = self.get_entity_values(error_dict) entity_keys = list(error_dict) diff --git a/netsuitesdk/internal/client.py b/netsuitesdk/internal/client.py index 72786d2..50ac36b 100644 --- a/netsuitesdk/internal/client.py +++ b/netsuitesdk/internal/client.py @@ -517,10 +517,13 @@ def upsert(self, record, record_type=None): exc = self._request_error('upsert', detail=status['statusDetail'][0]) if record_type: - error_parser = ErrorParser(self.get) - error_dict = export_error_matcher(exc.message, record_type) - message = error_parser.export_error_parser(error_dict, exc.message) - exc.message = message + try: + error_parser = ErrorParser(self.get) + error_dict = export_error_matcher(exc.message, record_type) + message = error_parser.export_error_parser(error_dict, exc.message) + exc.message = message + except Exception as e: + self.logger.debug('Error parsing error message', e.message) raise exc diff --git a/setup.py b/setup.py index a5e82a7..6df6055 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='netsuitesdk', - version='2.19.1', + version='2.19.2', author='Siva Narayanan', author_email='siva@fyle.in', description='Python SDK for accessing the NetSuite SOAP webservice',