Skip to content

Commit 512eb12

Browse files
Enhance error message with error help portal URL.
1 parent 531f3fc commit 512eb12

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Thin Mode Changes
2929
#) Added support for growing the pool back to the minimum number of
3030
connections allowed in the pool when connections are killed or otherwise
3131
made unusable.
32+
#) Added URL to the Oracle Database Error Help Portal in Oracle Database
33+
error messages similar to when Thick mode uses Oracle Client 23c.
3234
#) A default connection class is now generated when DRCP is used with a
3335
connection pool and no connection class was specified when the pool was
3436
created. The default connection class will be of the form ``DPY:`` followed

src/oracledb/errors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import re
3535

36+
from .driver_mode import is_thin_mode
3637
from . import exceptions
3738

3839
class _Error:
@@ -62,6 +63,14 @@ def _make_adjustments(self):
6263
pos = self.message.find(":")
6364
if pos > 0:
6465
self.full_code = self.message[:pos]
66+
67+
# add Oracle Database Error Help Portal URL for database error
68+
# messages, but only in thin mode since this is done
69+
# automatically in thick mode with Oracle Client 23c and higher
70+
if self.code != 0 and is_thin_mode():
71+
self.message = self.message + "\n" + \
72+
"Help: https://docs.oracle.com/error-help/db/ora-" + \
73+
f"{self.code:05}/"
6574
if self.code != 0 or self.full_code.startswith("DPI-"):
6675
args = {}
6776
if self.code != 0:

tests/test_1700_error.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"""
2828

2929
import pickle
30+
import unittest
3031

3132
import oracledb
3233
import test_env
@@ -83,5 +84,16 @@ def test_1702_error_full_code(self):
8384
error_obj, = cm.exception.args
8485
self.assertEqual(error_obj.full_code, "DPI-1037")
8586

87+
@unittest.skipIf(test_env.get_client_version() < (23, 1),
88+
"unsupported client")
89+
def test_1703_error_help_url(self):
90+
"1703 - test generation of error help portal URL"
91+
cursor = self.connection.cursor()
92+
with self.assertRaises(oracledb.Error) as cm:
93+
cursor.execute("select 1 / 0 from dual")
94+
error_obj, = cm.exception.args
95+
to_check = "Help: https://docs.oracle.com/error-help/db/ora-01476/"
96+
self.assertIn(to_check, error_obj.message)
97+
8698
if __name__ == "__main__":
8799
test_env.run_test_cases()

0 commit comments

Comments
 (0)