@@ -110,6 +110,8 @@ def _raise_err(error_num: int, context_error_message: str=None,
110110 supplied arguments.
111111 """
112112 message = _get_error_text (error_num , ** args )
113+ if context_error_message is None and cause is not None :
114+ context_error_message = str (cause )
113115 if context_error_message is not None :
114116 message = f"{ message } \n { context_error_message } "
115117 exc_type = ERR_EXCEPTION_TYPES [error_num // 1000 ]
@@ -307,7 +309,7 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
307309 'column truncated to {col_value_len} {unit}. '
308310 'Untruncated was {actual_len}' ,
309311 ERR_CONNECTION_FAILED :
310- 'cannot connect to database. Connection failed with "{exception}" ' ,
312+ 'cannot connect to database.' ,
311313 ERR_CONTENT_INVALID_AFTER_NUMBER :
312314 'invalid number (content after number)' ,
313315 ERR_CURSOR_NOT_OPEN :
@@ -386,25 +388,22 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
386388 ERR_INVALID_REF_CURSOR :
387389 'invalid REF CURSOR: never opened in PL/SQL' ,
388390 ERR_INVALID_SERVER_CERT_DN :
389- 'cannot connect to database. The distinguished name (DN) on '
390- 'the server certificate does not match the expected value' ,
391+ 'The distinguished name (DN) on the server certificate does not '
392+ 'match the expected value' ,
391393 ERR_INVALID_SERVER_TYPE :
392394 'invalid server_type: {server_type}' ,
393395 ERR_INVALID_SERVICE_NAME :
394- 'cannot connect to database. Service "{service_name}" is not '
395- 'registered with the listener at host "{host}" port {port}. '
396- '(Similar to ORA-12514)' ,
396+ 'Service "{service_name}" is not registered with the listener at '
397+ 'host "{host}" port {port}. (Similar to ORA-12514)' ,
397398 ERR_INVALID_SID :
398- 'cannot connect to database. SID "{sid}" is not registered '
399- 'with the listener at host "{host}" port {port}. '
400- '(Similar to ORA-12505)' ,
399+ 'SID "{sid}" is not registered with the listener at host "{host}" '
400+ 'port {port}. (Similar to ORA-12505)' ,
401401 ERR_KEYWORD_ARGS_MUST_BE_DICT :
402402 '"keyword_parameters" argument must be a dict' ,
403403 ERR_LIBRARY_ALREADY_INITIALIZED :
404404 'init_oracle_client() was already called with different arguments' ,
405405 ERR_LISTENER_REFUSED_CONNECTION :
406- 'cannot connect to database. Listener refused connection. '
407- '(Similar to ORA-{error_code})' ,
406+ 'Listener refused connection. (Similar to ORA-{error_code})' ,
408407 ERR_LOB_OF_WRONG_TYPE :
409408 'LOB is of type {actual_type_name} but must be of type '
410409 '{expected_type_name}' ,
@@ -488,11 +487,9 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
488487 ERR_TIME_NOT_SUPPORTED :
489488 'Oracle Database does not support time only variables' ,
490489 ERR_TNS_ENTRY_NOT_FOUND :
491- 'cannot connect to database. Unable to find "{name}" in '
492- '{file_name}' ,
490+ 'unable to find "{name}" in {file_name}' ,
493491 ERR_TNS_NAMES_FILE_MISSING :
494- 'cannot connect to database. File tnsnames.ora not found in '
495- '{config_dir}' ,
492+ 'file tnsnames.ora not found in {config_dir}' ,
496493 ERR_UNEXPECTED_DATA :
497494 'unexpected data received: {data}' ,
498495 ERR_UNEXPECTED_END_OF_DATA :
@@ -517,7 +514,7 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
517514 'password verifier type 0x{verifier_type:x} is not supported by '
518515 'python-oracledb in thin mode' ,
519516 ERR_WALLET_FILE_MISSING :
520- 'cannot connect to database. Wallet file {name} was not found' ,
517+ 'wallet file {name} was not found' ,
521518 ERR_WRONG_ARRAY_DEFINITION :
522519 'expecting a list of two elements [type, numelems]' ,
523520 ERR_WRONG_EXECUTE_PARAMETERS_TYPE :
0 commit comments