Wednesday, 3 May 2017

Error not directed to catch block

I am using the mssql module in Node.js.

I have the following where date is a column of smalldatetime:

var qs = "select * from T1 where date='2017-04-31';
new sql.Request().query(qs).then(function (result) {
        return callback(null, result);
      }).catch(function (err) {
        return callback(err);
      });

The value given in the date filter is invalid of type smalldatetime, but the catch block is not called. Instead it generated the following error:

(node:11172) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Cannot read property '0' of undefined`

Am I using the then/catch pattern correctly or is this likely to be a bug in the module?



via Old Geezer

No comments:

Post a Comment