Skip to content

Commit 4897169

Browse files
jaeadamsdocktermj
andauthored
Issue 92.team.1 (#117)
* #92 Exact copy of g2-python/g2/python issue-104.team.1 branch * #92 Exact copy of g2-python/g2/python issue-104.team.1 branch * #92 fix syntax * #92 fix whitespace * #92 Fix string/int argument preparation functions, to not default to None values or literals. * Issue 95.dockter.1 (#96) * #95 Add __all__ * #95 Add __all__ * #95 Add __all__ * #95 - Update to new SDK * #95 - Update to new SDK * Issue 93.dockter.2 (#97) * #93 Working code * #93 Working code * #93 Working code * #93 Working code * #93 Working code * #93 Working code * #98 Add G2EngineFlags.combine_flags() (#99) * #98 Add G2EngineFlags.combine_flags() * #98 Added testcase * #93 Add test for large enums (#101) * Fixes to the EngineFlags, to match the G2 V3.0 release. * #92 Add feature scores to the how-function and why-function default bitmasks. * #106 Format to PEP-8 (#107) * #105 Savepoint * #105 Deprecate V2 * #105 Deprecate V2 * #105 Add *args, **kwargs * #105 Add *args, **kwargs * #105 Add *args, **kwargs * #105 Add *args, **kwargs * #105 Add *args, **kwargs * #105 Add *args, **kwargs * #105 Add *args, **kwargs * #108 Remove Exceptions not used by SDK * #94 Savepoint * #105 Rearrange parameters * #105 Touch-ups * #105 Touch-ups * #105 Fix flags * #94 Savepoint * #94 Cleanup * #94 Remove G2ModuleMySQLNoSchema * Remove a reference to the deleted MySQL exception type. * #112 Accept string and bytearray in TranslateG2ModuleException * #92 Fixes for some API functions. * #92 Fix a bug in creating G2 exceptions. * Fix some bugs related to flags and load IDs. * #115 Add G2DatabaseConnectionLost * Update CHANGELOG.md Co-authored-by: michael@dockter.com <michael@dockter.com> Co-authored-by: Michael Dockter <docktermj@users.noreply.github.com>
1 parent 8b2ae71 commit 4897169

16 files changed

+1955
-2846
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
[markdownlint](https://dlaa.me/markdownlint/),
77
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [3.0.0] - 2022-05-04
10+
11+
### Added to 3.0.0
12+
13+
- Support SenzingAPI 3.0.0
14+
915
## [2.8.7] - 2022-03-01
1016

1117
### Changed in 2.8.7

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ install-test:
7272
.PHONY: test
7373
test:
7474
tests/test-imports.py
75+
tests/test-g2engineflags.py
7576

7677
# -----------------------------------------------------------------------------
7778
# uninstall

src/senzing/G2Config.py

Lines changed: 154 additions & 1328 deletions
Large diffs are not rendered by default.

src/senzing/G2ConfigMgr.py

Lines changed: 156 additions & 123 deletions
Large diffs are not rendered by default.

src/senzing/G2Diagnostic.py

Lines changed: 217 additions & 262 deletions
Large diffs are not rendered by default.

src/senzing/G2Engine.py

Lines changed: 531 additions & 854 deletions
Large diffs are not rendered by default.

src/senzing/G2EngineFlags.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from enum import IntFlag
2+
3+
__all__ = ['G2EngineFlags']
4+
5+
6+
class G2EngineFlags(IntFlag):
7+
8+
@classmethod
9+
def combine_flags(cls, list_of_strings, *args, **kwargs):
10+
''' OR together all strings in list_of_strings '''
11+
12+
result = 0
13+
for string in list_of_strings:
14+
result = result | G2EngineFlags[string]
15+
return result
16+
17+
# Flags for exporting entity data.
18+
19+
G2_EXPORT_INCLUDE_RESOLVED = (1 << 0)
20+
G2_EXPORT_INCLUDE_POSSIBLY_SAME = (1 << 1)
21+
G2_EXPORT_INCLUDE_POSSIBLY_RELATED = (1 << 2)
22+
G2_EXPORT_INCLUDE_NAME_ONLY = (1 << 3)
23+
G2_EXPORT_INCLUDE_DISCLOSED = (1 << 4)
24+
G2_EXPORT_INCLUDE_SINGLETONS = (1 << 5)
25+
G2_EXPORT_INCLUDE_ALL_ENTITIES = G2_EXPORT_INCLUDE_RESOLVED | G2_EXPORT_INCLUDE_SINGLETONS
26+
G2_EXPORT_INCLUDE_ALL_RELATIONSHIPS = G2_EXPORT_INCLUDE_POSSIBLY_SAME | G2_EXPORT_INCLUDE_POSSIBLY_RELATED | G2_EXPORT_INCLUDE_NAME_ONLY | G2_EXPORT_INCLUDE_DISCLOSED
27+
28+
# Flags for outputting entity relation data.
29+
30+
G2_ENTITY_INCLUDE_POSSIBLY_SAME_RELATIONS = (1 << 6)
31+
G2_ENTITY_INCLUDE_POSSIBLY_RELATED_RELATIONS = (1 << 7)
32+
G2_ENTITY_INCLUDE_NAME_ONLY_RELATIONS = (1 << 8)
33+
G2_ENTITY_INCLUDE_DISCLOSED_RELATIONS = (1 << 9)
34+
G2_ENTITY_INCLUDE_ALL_RELATIONS = G2_ENTITY_INCLUDE_POSSIBLY_SAME_RELATIONS | G2_ENTITY_INCLUDE_POSSIBLY_RELATED_RELATIONS | G2_ENTITY_INCLUDE_NAME_ONLY_RELATIONS | G2_ENTITY_INCLUDE_DISCLOSED_RELATIONS
35+
36+
# Flags for outputting entity feature data.
37+
38+
G2_ENTITY_INCLUDE_ALL_FEATURES = (1 << 10)
39+
G2_ENTITY_INCLUDE_REPRESENTATIVE_FEATURES = (1 << 11)
40+
41+
# Flags for getting extra information about an entity.
42+
43+
G2_ENTITY_INCLUDE_ENTITY_NAME = (1 << 12)
44+
G2_ENTITY_INCLUDE_RECORD_SUMMARY = (1 << 13)
45+
G2_ENTITY_INCLUDE_RECORD_DATA = (1 << 14)
46+
G2_ENTITY_INCLUDE_RECORD_MATCHING_INFO = (1 << 15)
47+
G2_ENTITY_INCLUDE_RECORD_JSON_DATA = (1 << 16)
48+
G2_ENTITY_INCLUDE_RECORD_FORMATTED_DATA = (1 << 17)
49+
G2_ENTITY_INCLUDE_RECORD_FEATURE_IDS = (1 << 18)
50+
G2_ENTITY_INCLUDE_RELATED_ENTITY_NAME = (1 << 19)
51+
G2_ENTITY_INCLUDE_RELATED_MATCHING_INFO = (1 << 20)
52+
G2_ENTITY_INCLUDE_RELATED_RECORD_SUMMARY = (1 << 21)
53+
G2_ENTITY_INCLUDE_RELATED_RECORD_DATA = (1 << 22)
54+
55+
# Flags for extra feature data.
56+
57+
G2_ENTITY_OPTION_INCLUDE_INTERNAL_FEATURES = (1 << 23)
58+
G2_ENTITY_OPTION_INCLUDE_FEATURE_STATS = (1 << 24)
59+
60+
# Flags for finding entity path data.
61+
62+
G2_FIND_PATH_PREFER_EXCLUDE = (1 << 25)
63+
64+
# Flags for including search result information.
65+
66+
G2_INCLUDE_FEATURE_SCORES = (1 << 26)
67+
G2_SEARCH_INCLUDE_STATS = (1 << 27)
68+
G2_SEARCH_INCLUDE_FEATURE_SCORES = G2_INCLUDE_FEATURE_SCORES
69+
70+
# Flags for exporting entity data.
71+
72+
G2_SEARCH_INCLUDE_RESOLVED = G2_EXPORT_INCLUDE_RESOLVED
73+
G2_SEARCH_INCLUDE_POSSIBLY_SAME = G2_EXPORT_INCLUDE_POSSIBLY_SAME
74+
G2_SEARCH_INCLUDE_POSSIBLY_RELATED = G2_EXPORT_INCLUDE_POSSIBLY_RELATED
75+
G2_SEARCH_INCLUDE_NAME_ONLY = G2_EXPORT_INCLUDE_NAME_ONLY
76+
G2_SEARCH_INCLUDE_ALL_ENTITIES = G2_SEARCH_INCLUDE_RESOLVED | G2_SEARCH_INCLUDE_POSSIBLY_SAME | G2_SEARCH_INCLUDE_POSSIBLY_RELATED | G2_SEARCH_INCLUDE_NAME_ONLY
77+
78+
# Recommended settings.
79+
80+
G2_RECORD_DEFAULT_FLAGS = G2_ENTITY_INCLUDE_RECORD_JSON_DATA
81+
G2_ENTITY_DEFAULT_FLAGS = G2_ENTITY_INCLUDE_ALL_RELATIONS | G2_ENTITY_INCLUDE_REPRESENTATIVE_FEATURES | G2_ENTITY_INCLUDE_ENTITY_NAME | G2_ENTITY_INCLUDE_RECORD_SUMMARY | G2_ENTITY_INCLUDE_RECORD_DATA | G2_ENTITY_INCLUDE_RECORD_MATCHING_INFO | G2_ENTITY_INCLUDE_RELATED_ENTITY_NAME | G2_ENTITY_INCLUDE_RELATED_RECORD_SUMMARY | G2_ENTITY_INCLUDE_RELATED_MATCHING_INFO
82+
G2_ENTITY_BRIEF_DEFAULT_FLAGS = G2_ENTITY_INCLUDE_RECORD_MATCHING_INFO | G2_ENTITY_INCLUDE_ALL_RELATIONS | G2_ENTITY_INCLUDE_RELATED_MATCHING_INFO
83+
G2_EXPORT_DEFAULT_FLAGS = G2_EXPORT_INCLUDE_ALL_ENTITIES | G2_EXPORT_INCLUDE_ALL_RELATIONSHIPS | G2_ENTITY_INCLUDE_ALL_RELATIONS | G2_ENTITY_INCLUDE_REPRESENTATIVE_FEATURES | G2_ENTITY_INCLUDE_ENTITY_NAME | G2_ENTITY_INCLUDE_RECORD_DATA | G2_ENTITY_INCLUDE_RECORD_MATCHING_INFO | G2_ENTITY_INCLUDE_RELATED_MATCHING_INFO
84+
G2_FIND_PATH_DEFAULT_FLAGS = G2_ENTITY_INCLUDE_ALL_RELATIONS | G2_ENTITY_INCLUDE_ENTITY_NAME | G2_ENTITY_INCLUDE_RECORD_SUMMARY | G2_ENTITY_INCLUDE_RELATED_MATCHING_INFO
85+
G2_WHY_ENTITY_DEFAULT_FLAGS = G2_ENTITY_DEFAULT_FLAGS | G2_ENTITY_INCLUDE_RECORD_FEATURE_IDS | G2_ENTITY_OPTION_INCLUDE_INTERNAL_FEATURES | G2_ENTITY_OPTION_INCLUDE_FEATURE_STATS | G2_INCLUDE_FEATURE_SCORES
86+
G2_HOW_ENTITY_DEFAULT_FLAGS = G2_ENTITY_DEFAULT_FLAGS | G2_ENTITY_INCLUDE_RECORD_FEATURE_IDS | G2_ENTITY_OPTION_INCLUDE_INTERNAL_FEATURES | G2_ENTITY_OPTION_INCLUDE_FEATURE_STATS | G2_INCLUDE_FEATURE_SCORES
87+
88+
G2_SEARCH_BY_ATTRIBUTES_ALL = G2_SEARCH_INCLUDE_ALL_ENTITIES | G2_ENTITY_INCLUDE_REPRESENTATIVE_FEATURES | G2_ENTITY_INCLUDE_ENTITY_NAME | G2_ENTITY_INCLUDE_RECORD_SUMMARY | G2_SEARCH_INCLUDE_FEATURE_SCORES
89+
G2_SEARCH_BY_ATTRIBUTES_STRONG = G2_SEARCH_INCLUDE_RESOLVED | G2_SEARCH_INCLUDE_POSSIBLY_SAME | G2_ENTITY_INCLUDE_REPRESENTATIVE_FEATURES | G2_ENTITY_INCLUDE_ENTITY_NAME | G2_ENTITY_INCLUDE_RECORD_SUMMARY | G2_SEARCH_INCLUDE_FEATURE_SCORES
90+
G2_SEARCH_BY_ATTRIBUTES_MINIMAL_ALL = G2_SEARCH_INCLUDE_ALL_ENTITIES
91+
G2_SEARCH_BY_ATTRIBUTES_MINIMAL_STRONG = G2_SEARCH_INCLUDE_RESOLVED | G2_SEARCH_INCLUDE_POSSIBLY_SAME
92+
G2_SEARCH_BY_ATTRIBUTES_DEFAULT_FLAGS = G2_SEARCH_BY_ATTRIBUTES_ALL

src/senzing/G2Exception.py

Lines changed: 187 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,233 @@
1+
__all__ = [
2+
'G2BadInputException',
3+
'G2ConfigurationException',
4+
'G2Exception',
5+
'G2IncompleteRecordException',
6+
'G2MalformedJsonException',
7+
'G2MessageBufferException',
8+
'G2MissingConfigurationException',
9+
'G2MissingDataSourceException',
10+
'G2ModuleEmptyMessage',
11+
'G2ModuleException',
12+
'G2ModuleGenericException',
13+
'G2ModuleInvalidXML',
14+
'G2ModuleLicenseException',
15+
'G2ModuleNotInitialized',
16+
'G2ModuleResolveMissingResEnt',
17+
'G2RepositoryPurgedException',
18+
'G2RetryableException',
19+
'G2UnacceptableJsonKeyValueException',
20+
'G2UnrecoverableException',
21+
'TranslateG2ModuleException',
22+
]
23+
24+
# -----------------------------------------------------------------------------
25+
# Base G2Exception
26+
# -----------------------------------------------------------------------------
127

228

329
class G2Exception(Exception):
430
'''Base exception for G2 related python code'''
31+
532
def __init__(self, *args, **kwargs):
6-
Exception.__init__(self, *args, **kwargs)
33+
super().__init__(self, *args, **kwargs)
34+
35+
# -----------------------------------------------------------------------------
36+
# Category exceptions
37+
# - These exceptions represent categories of actions that can be taken by
38+
# the calling program.
39+
# - G2BadInputException - The user-supplied input contained an error.
40+
# - G2RetryableException - The program can provide a remedy and continue.
41+
# - G2UnrecoverableException - System failure; can't continue.
42+
# -----------------------------------------------------------------------------
43+
44+
45+
class G2BadInputException(G2Exception):
746

8-
class G2UnsupportedFileTypeException(G2Exception):
947
def __init__(self, *args, **kwargs):
10-
G2Exception.__init__(self, *args, **kwargs)
48+
super().__init__(self, *args, **kwargs)
49+
50+
51+
class G2RetryableException(G2Exception):
1152

12-
class G2InvalidFileTypeContentsException(G2Exception):
1353
def __init__(self, *args, **kwargs):
14-
G2Exception.__init__(self, *args, **kwargs)
54+
super().__init__(self, *args, **kwargs)
55+
56+
57+
class G2UnrecoverableException(G2Exception):
1558

16-
class G2DBException(G2Exception):
17-
'''Base exception for G2 DB related python code'''
1859
def __init__(self, *args, **kwargs):
19-
G2Exception.__init__(self, *args, **kwargs)
60+
super().__init__(self, *args, **kwargs)
2061

21-
class UnconfiguredDataSourceException(G2Exception):
22-
def __init__(self, DataSourceName):
23-
G2Exception.__init__(self,("Datasource %s not configured. See https://senzing.zendesk.com/hc/en-us/articles/360010784333 on how to configure datasources in the config file." % DataSourceName ))
62+
# -----------------------------------------------------------------------------
63+
# Detail exceptions for G2BadInputException
64+
# - Processing did not complete.
65+
# - These exceptions are "per record" exceptions.
66+
# - The record should be recorded as "bad". (logged, queued as failure)
67+
# - Processing may continue.
68+
# -----------------------------------------------------------------------------
69+
70+
71+
class G2IncompleteRecordException(G2BadInputException):
2472

25-
class G2DBUnknownException(G2DBException):
2673
def __init__(self, *args, **kwargs):
27-
G2DBException.__init__(self, *args, **kwargs)
74+
super().__init__(self, *args, **kwargs)
75+
76+
77+
class G2MalformedJsonException(G2BadInputException):
2878

29-
class G2UnsupportedDatabaseType(G2DBException):
3079
def __init__(self, *args, **kwargs):
31-
G2DBException.__init__(self, *args, **kwargs)
80+
super().__init__(self, *args, **kwargs)
81+
82+
83+
class G2MissingConfigurationException(G2BadInputException):
3284

33-
class G2TableNoExist(G2DBException):
3485
def __init__(self, *args, **kwargs):
35-
G2DBException.__init__(self, *args, **kwargs)
86+
super().__init__(self, *args, **kwargs)
87+
88+
89+
class G2MissingDataSourceException(G2BadInputException):
90+
91+
def __init__(self, *args, **kwargs):
92+
super().__init__(self, *args, **kwargs)
93+
94+
95+
class G2UnacceptableJsonKeyValueException(G2BadInputException):
96+
97+
def __init__(self, *args, **kwargs):
98+
super().__init__(self, *args, **kwargs)
99+
100+
# -----------------------------------------------------------------------------
101+
# Detail exceptions for G2RetryableException
102+
# - Processing did not complete.
103+
# - These exceptions may be remedied programmatically.
104+
# - The call to the Senzing method should be retried.
105+
# - Processing may continue.
106+
# -----------------------------------------------------------------------------
107+
108+
109+
class G2ConfigurationException(G2RetryableException):
110+
111+
def __init__(self, *args, **kwargs):
112+
super().__init__(self, *args, **kwargs)
113+
114+
115+
class G2DatabaseConnectionLost(G2RetryableException):
36116

37-
class G2DBMNotStarted(G2DBException):
38117
def __init__(self, *args, **kwargs):
39-
G2DBException.__init__(self, *args, **kwargs)
118+
super().__init__(self, *args, **kwargs)
119+
120+
121+
class G2MessageBufferException(G2RetryableException):
40122

41-
class G2DBNotFound(G2DBException):
42123
def __init__(self, *args, **kwargs):
43-
G2DBException.__init__(self, *args, **kwargs)
124+
super().__init__(self, *args, **kwargs)
125+
126+
127+
class G2RepositoryPurgedException(G2RetryableException):
44128

45-
class G2DBUniqueConstraintViolation(G2DBException):
46129
def __init__(self, *args, **kwargs):
47-
G2DBException.__init__(self, *args, **kwargs)
130+
super().__init__(self, *args, **kwargs)
131+
132+
# -----------------------------------------------------------------------------
133+
# Detail exceptions for G2UnrecoverableException
134+
# - Processing did not complete.
135+
# - These exceptions cannot be remedied programmatically.
136+
# - Processing cannot continue.
137+
# -----------------------------------------------------------------------------
138+
48139

49140
class G2ModuleException(G2Exception):
50141
'''Base exception for G2 Module related python code'''
142+
51143
def __init__(self, *args, **kwargs):
52-
G2Exception.__init__(self, *args, **kwargs)
144+
super().__init__(self, *args, **kwargs)
145+
146+
147+
class G2ModuleEmptyMessage(G2ModuleException):
53148

54-
class G2ModuleNotInitialized(G2ModuleException):
55-
'''G2 Module called but has not been initialized '''
56149
def __init__(self, *args, **kwargs):
57-
G2ModuleException.__init__(self, *args, **kwargs)
150+
super().__init__(self, *args, **kwargs)
151+
58152

59153
class G2ModuleGenericException(G2ModuleException):
60154
'''Generic exception for non-subclassed G2 Module exception '''
155+
61156
def __init__(self, *args, **kwargs):
62-
G2ModuleException.__init__(self, *args, **kwargs)
157+
super().__init__(self, *args, **kwargs)
158+
159+
160+
class G2ModuleInvalidXML(G2ModuleException):
63161

64-
class G2ModuleMySQLNoSchema(G2ModuleException):
65162
def __init__(self, *args, **kwargs):
66-
G2ModuleException.__init__(self, *args, **kwargs)
163+
super().__init__(self, *args, **kwargs)
164+
165+
166+
class G2ModuleLicenseException(G2ModuleException):
67167

68-
class G2ModuleEmptyMessage(G2ModuleException):
69168
def __init__(self, *args, **kwargs):
70-
G2ModuleException.__init__(self, *args, **kwargs)
169+
super().__init__(self, *args, **kwargs)
170+
171+
172+
class G2ModuleNotInitialized(G2ModuleException):
173+
'''G2 Module called but has not been initialized '''
71174

72-
class G2ModuleInvalidXML(G2ModuleException):
73175
def __init__(self, *args, **kwargs):
74-
G2ModuleException.__init__(self, *args, **kwargs)
176+
super().__init__(self, *args, **kwargs)
177+
75178

76179
class G2ModuleResolveMissingResEnt(G2ModuleException):
77-
def __init__(self, *args, **kwargs):
78-
G2ModuleException.__init__(self, *args, **kwargs)
79180

80-
class G2ModuleLicenseException(G2ModuleException):
81181
def __init__(self, *args, **kwargs):
82-
G2ModuleException.__init__(self, *args, **kwargs)
83-
84-
def TranslateG2ModuleException(ex):
85-
exInfo = ex.decode().split('|', 1)
86-
if exInfo[0] == '7213E':
87-
return G2ModuleMySQLNoSchema(ex)
88-
elif exInfo[0] == '0002E':
89-
return G2ModuleInvalidXML(ex.decode())
90-
elif exInfo[0] == '0007E':
91-
return G2ModuleEmptyMessage(ex.decode())
92-
elif exInfo[0] == '2134E':
93-
return G2ModuleResolveMissingResEnt(ex.decode())
94-
elif exInfo[0] == '9000E':
95-
return G2ModuleLicenseException(ex.decode())
182+
super().__init__(self, *args, **kwargs)
183+
184+
# -----------------------------------------------------------------------------
185+
# Determine Exception based on Senzing reason code.
186+
# Reference: https://senzing.zendesk.com/hc/en-us/articles/360026678133-Engine-Error-codes
187+
# -----------------------------------------------------------------------------
188+
189+
190+
exceptions_map = {
191+
"0002E": G2ModuleInvalidXML,
192+
"0007E": G2ModuleEmptyMessage,
193+
"0023E": G2UnacceptableJsonKeyValueException,
194+
"0024E": G2UnacceptableJsonKeyValueException,
195+
"0025E": G2UnacceptableJsonKeyValueException,
196+
"0026E": G2UnacceptableJsonKeyValueException,
197+
"0027E": G2UnacceptableJsonKeyValueException,
198+
"0032E": G2UnacceptableJsonKeyValueException,
199+
"0034E": G2ConfigurationException,
200+
"0035E": G2ConfigurationException,
201+
"0036E": G2ConfigurationException,
202+
"0051E": G2UnacceptableJsonKeyValueException,
203+
"0054E": G2RepositoryPurgedException,
204+
"0061E": G2ConfigurationException,
205+
"0062E": G2ConfigurationException,
206+
"0064E": G2ConfigurationException,
207+
"1007E": G2DatabaseConnectionLost,
208+
"2134E": G2ModuleResolveMissingResEnt,
209+
"9000E": G2ModuleLicenseException,
210+
"30020": G2UnacceptableJsonKeyValueException,
211+
"30110E": G2MessageBufferException,
212+
"30111E": G2MessageBufferException,
213+
"30112E": G2MessageBufferException,
214+
"30121E": G2MalformedJsonException,
215+
"30122E": G2MalformedJsonException,
216+
"30123E": G2MalformedJsonException,
217+
}
218+
219+
220+
def TranslateG2ModuleException(exception_message):
221+
222+
if exception_message is None:
223+
exception_message_string = ''
224+
elif isinstance(exception_message, bytearray):
225+
exception_message_string = exception_message.decode()
226+
elif isinstance(exception_message, bytes):
227+
exception_message_string = exception_message.decode()
96228
else:
97-
return G2ModuleGenericException(ex.decode())
229+
exception_message_string = exception_message
98230

231+
senzing_error_code = exception_message_string.split('|', 1)[0].strip()
232+
senzing_error_class = exceptions_map.get(senzing_error_code, G2Exception)
233+
return senzing_error_class(exception_message_string)

0 commit comments

Comments
 (0)