Skip to content

Commit f896ef9

Browse files
authored
fix: Better optional deps handling (#353)
odbc and idb-connector are optional deps and might not be installed. When either is not available, return an error back to user instead of failing.
1 parent b67bfcf commit f896ef9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/transports/idbTransport.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ try {
2828
}
2929

3030
function idbCall(config, xmlInput, cb) {
31+
// idb transport is not available bail out
32+
if (idb === null) {
33+
cb(new Error('idb-connector was not found, ensure idb-connector is installed properly (idb-connector is only available on IBM i).'), null);
34+
}
35+
3136
const {
3237
database = '*LOCAL',
3338
username = null,

lib/transports/odbcTransport.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ try {
2828
}
2929

3030
function odbcCall(config, xmlInput, done) {
31+
// odbc transport is not available bail out
32+
if (odbc === null) {
33+
done(new Error('odbc transport was not found, ensure odbc is installed properly.'), null);
34+
}
35+
3136
const {
3237
host = 'localhost',
3338
username = null,

0 commit comments

Comments
 (0)