Skip to content

Commit 2c08dbb

Browse files
committed
Rework bootstrap failure messages (@kubo, @bchr02)
1 parent 96aa778 commit 2c08dbb

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,8 +1445,8 @@ If `npm install oracledb` fails:
14451445

14461446
If `require('oracledb')` fails:
14471447

1448-
- If you got **DPI-1047: Oracle Client library cannot be loaded** or
1449-
**NJS-045: cannot load the oracledb add-on binary for Node.js**,
1448+
- If you got **NJS-045: cannot load the oracledb add-on binary for
1449+
Node.js** or **DPI-1047: Oracle Client library cannot be loaded**,
14501450
then review any messages and the installation instructions.
14511451

14521452
- Does your Node.js architecture (32-bit or 64-bit) match the Oracle

lib/oracledb.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,32 @@ var binaryDebugPath = '../build/Debug/oracledb.node';
4141
try {
4242
oracledbCLib = require(binaryReleasePath);
4343
} catch (err) {
44-
if (err.code !== 'MODULE_NOT_FOUND') {
45-
throw err;
46-
} else {
44+
var nodeInfo = process.versions.node + ' (' + process.platform + ', ' + process.arch +')\n';
45+
var fullReleasePath = require('path').resolve(__dirname, binaryReleasePath);
46+
if (err.code === 'MODULE_NOT_FOUND') {
4747
try {
4848
oracledbCLib = require(binaryDebugPath);
4949
} catch (err) {
50-
if (err.code !== 'MODULE_NOT_FOUND') {
51-
throw err;
50+
if (err.code === 'MODULE_NOT_FOUND') {
51+
// Neither Release or Debug binary was found but assume users wanted Release binary
52+
nodeInfo += 'Cannot find module ' + fullReleasePath + '\n' + getInfo();
53+
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
5254
} else {
53-
var nodeInfo = process.versions.node + ' (' + process.platform + ', ' + process.arch +')\n';
54-
var fullPath = require('path').resolve(__dirname, binaryReleasePath);
55-
try {
56-
require('fs').statSync(fullPath);
57-
nodeInfo += getInfo(); // file exists, so get message about Oracle Client
58-
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
59-
} catch(err) {
60-
// file couldn't be found
61-
nodeInfo += 'Cannot read ' + fullPath + '\n' + err.message;
62-
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
63-
}
55+
nodeInfo += 'Cannot load ' + binaryDebugPath + '\n';
56+
nodeInfo += 'Node.js require() error was: \n ' + err.message + '\n' + getInfo();
57+
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
6458
}
6559
}
60+
} else {
61+
if (err.message.startsWith('DPI-1047:')) {
62+
// Release add-on binary loaded OK, but ODPI-C can't load Oracle client
63+
nodeInfo += 'Node.js require() error was: \n ' + err.message + '\n';
64+
nodeInfo += 'Node.js require() mapped to ' + fullReleasePath + '\n' + getInfo();
65+
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
66+
} else {
67+
nodeInfo += 'Cannot load ' + fullReleasePath + '\n' + err.message + '\n' + getInfo();
68+
throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
69+
}
6670
}
6771
}
6872

@@ -72,9 +76,10 @@ oracledbCLib.Oracledb.prototype.newLob = function(iLob) {
7276

7377

7478
// Return a string with installation usage tips that may be helpful
75-
// (although ODPI-C should catch most cases)
7679
function getInfo() {
7780
var arch, url, mesg = '';
81+
mesg = 'Node-oracledb installation instructions: ';
82+
mesg += 'https://github.com/oracle/node-oracledb/blob/master/INSTALL.md\n';
7883
if (process.platform === 'linux') {
7984
if (process.arch === 'x64') {
8085
url = 'http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html\n';
@@ -84,14 +89,13 @@ function getInfo() {
8489
arch = '32-bit';
8590
}
8691
mesg += 'You must have ' + arch + ' Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.\n';
87-
mesg += 'If you do not already have libraries, install the Instant Client Basic or Basic Light package from \n';
92+
mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from \n';
8893
mesg += url;
8994
} else if (process.platform === 'darwin') {
95+
url = 'http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html';
9096
if (process.arch === 'x64') {
91-
url = 'http://www.oracle.com/technetwork/topics/winx64soft-089540.html';
9297
arch = '64-bit';
9398
} else {
94-
url = 'http://www.oracle.com/technetwork/topics/winsoft-085727.html';
9599
arch = '32-bit';
96100
}
97101
mesg += 'You must have the ' + arch + ' Oracle Instant Client Basic or Basic Light package in ~/lib or /usr/local/lib\n';
@@ -105,7 +109,7 @@ function getInfo() {
105109
arch = '32-bit';
106110
}
107111
mesg += 'You must have ' + arch + ' Oracle client libraries in your PATH environment variable.\n';
108-
mesg += 'If you do not already have libraries, install the Instant Client Basic or Basic Light package from\n';
112+
mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from\n';
109113
mesg += url;
110114
mesg += 'A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.\n';
111115
} else {
@@ -116,11 +120,9 @@ function getInfo() {
116120
arch = '32-bit';
117121
}
118122
mesg += 'You must have ' + arch + ' Oracle client libraries in your operating system library search path.\n';
119-
mesg += 'If you do not already have libraries, install an Instant Client Basic or Basic Light package from: \n';
123+
mesg += 'If you do not have Oracle Database on this computer, then install an Instant Client Basic or Basic Light package from: \n';
120124
mesg += url;
121125
}
122-
mesg += 'Node-oracledb installation instructions: ';
123-
mesg += 'https://github.com/oracle/node-oracledb/blob/master/INSTALL.md\n\n';
124126
return mesg;
125127
}
126128

0 commit comments

Comments
 (0)