Skip to content

Commit bc06be2

Browse files
committed
Add Oracle Database Error Help Portal URL to ORA error messages
1 parent 3157d80 commit bc06be2

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ Thin Mode Changes
6666
in Thin mode instead of throwing an error. `Issue #1582
6767
<https://github.com/oracle/node-oracledb/issues/1582>`__.
6868

69+
#) Added support to expose database error cause/action URL in error messages.
70+
For ORA errors etc., the ERROR cause/action URL for that error code will
71+
be provided along with error message.
72+
6973
Thick Mode Changes
7074
++++++++++++++++++
7175

lib/errors.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,15 @@ function transformErr(err, fnOpt) {
608608
const pos = err.message.indexOf(":");
609609
if (pos > 0) {
610610
err.code = err.message.substr(0, pos);
611+
/* add Oracle Database Error Help Portal URL for database error
612+
messages, but only in thin mode since this is done
613+
automatically in thick mode with Oracle Client 23c and higher
614+
*/
615+
const settings = require('./settings.js');
616+
if (err.errorNum && settings.thin) {
617+
err.message += '\n' + 'Help: https://docs.oracle.com/error-help/db/ora-' +
618+
`${err.errorNum.toString().padStart(5, '0')}/`;
619+
}
611620
if (adjustErrorXref.has(err.code)) {
612621
let args = [];
613622
let driverErrorNum;

test/errorUrl.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* Copyright (c) 2023, Oracle and/or its affiliates. */
2+
3+
/******************************************************************************
4+
*
5+
* This software is dual-licensed to you under the Universal Permissive License
6+
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7+
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
8+
* either license.
9+
*
10+
* If you elect to accept the software under the Apache License, Version 2.0,
11+
* the following applies:
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the `License`);
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* https://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an `AS IS` BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*
25+
* NAME
26+
* 284. errorUrl.js
27+
*
28+
* DESCRIPTION
29+
* This test verifies enhancement to expose error portal URL in error message
30+
*
31+
*****************************************************************************/
32+
'use strict';
33+
34+
const oracledb = require('oracledb');
35+
const assert = require('assert');
36+
const dbConfig = require('./dbconfig.js');
37+
const testsUtil = require('./testsUtil.js');
38+
39+
describe('284. errorUrl.js', function() {
40+
41+
let conn;
42+
before(async function() {
43+
conn = await oracledb.getConnection(dbConfig);
44+
if (testsUtil.getClientVersion() < 2301000000) {
45+
this.skip();
46+
}
47+
});
48+
49+
after(async () => {
50+
await conn.close();
51+
});
52+
53+
it('284.1 checks for error URL in ORA error message', async () => {
54+
const url = /https:\/\/docs.oracle.com\/error-help\/db\/ora-01476\//;
55+
await assert.rejects(
56+
async () => await conn.execute(`SELECT 1/0 FROM DUAL`),
57+
(err) => {
58+
assert.match(err.message, url);
59+
return true;
60+
}
61+
);
62+
}); // 284.1
63+
64+
});

test/list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5485,3 +5485,6 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
54855485

54865486
283.aq5.js
54875487
283.1 subscribe dequeue messages
5488+
5489+
284. errorUrl.js
5490+
284.1 checks for error URL in ORA error message

test/opts/.mocharc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,5 @@ spec:
265265
- test/pipelinedTables.js
266266
- test/aq6.js
267267
- test/aq7.js
268+
- test/aq5.js
269+
- test/errorUrl.js

0 commit comments

Comments
 (0)