-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
bugSomething isn't workingSomething isn't workingkeep-openExempts stale action from auto closing the issue/pr.Exempts stale action from auto closing the issue/pr.
Description
- Node.js version: 12.19.0
- itoolkit version: latest master
- IBM i version: N/A
- XMLSERVICE version: N/A
Describe the bug
In #306, we added guards around requiring optional idb and odbc dependencies. If these dependencies are not installed and an unknowing user attempts to use the transports, the returned error messages are not really clear.
TypeError: Cannot read property 'dbconn' of null
at Connection.idbCall [as transportCall] (~/nodejs-itoolkit/lib/transports/idbTransport.js:48:24)
at Connection.run (~/nodejs-itoolkit/lib/Connection.js:187:10)
at Object.<anonymous> (~/nodejs-itoolkit/example.js:13:12)
TypeError: Cannot read property 'connect' of null
at Connection.odbcCall [as transportCall] (~/nodejs-itoolkit/lib/transports/odbcTransport.js:67:8)
at Connection.run (~/nodejs-itoolkit/lib/Connection.js:187:10)
at Object.<anonymous> (~/nodejs-itoolkit/example.js:13:12)
To Reproduce
Run the following snippet with transport set to idb or odbc on system without those modules installed. An easy example is using idb transport on your laptop given that idb-connector is only valid when run on IBM i systems.
const { Connection, CommandCall } = require('itoolkit');
const { parseString } = require('xml2js');
const connection = new Connection({
transport: 'idb',
transportOptions: { username: 'myuser', password: 'mypassword' },
});
const command = new CommandCall({ type: 'cl', command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)' });
connection.add(command);
connection.run((error, xmlOutput) => {
if (error) {
throw error;
}
parseString(xmlOutput, (parseError, result) => {
if (parseError) {
throw parseError;
}
console.log(JSON.stringify(result));
});
});Expected behavior
A more descriptive error message like the following:
Error: idb-connector module was not found, the idb transport is only valid IBM i systems
at ~/Connection.js:195:26
at Connection.idbCall [as transportCall] (~/nodejs-itoolkit/lib/transports/idbTransport.js:31:5)
at Connection.run (~/nodejs-itoolkit/lib/Connection.js:187:10)
at Object.<anonymous> (~/nodejs-itoolkit/example.js:13:12)
Error: odbc module was not found, ensure odbc is installed properly.
at ~/nodejs-itoolkit/lib/Connection.js:195:26
at Connection.odbcCall [as transportCall] (~/nodejs-itoolkit/lib/transports/odbcTransport.js:31:5)
at Connection.run (~/nodejs-itoolkit/lib/Connection.js:187:10)
at Object.<ano
nymous> (~/nodejs-itoolkit/example.js:13:12)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingkeep-openExempts stale action from auto closing the issue/pr.Exempts stale action from auto closing the issue/pr.