CodeFoodPixels / node-promise-mysql

A wrapper for mysqljs/mysql that wraps function calls with Bluebird promises.
MIT License
338 stars 64 forks source link

.catch(error) doesn't catch other errors #36

Closed oliverbytes closed 7 years ago

oliverbytes commented 7 years ago

For example, I will call an undefined function. It jumps to the catch event, but the error object is an empty object. but if there's a MySQL error the error object is not empty.

pool.getConnection().then(function(conn)
{
  connection = conn;

  return connection.query(SQL_PARAMS.options);

}).then(function(result) // SUCCESS
{
  // it knows there's an error here, but the error object on the catch(error) event is empty
  call_this_undefined_function();

  callback(null, "success");

}).catch(function(error) // ERROR: the 'error' object is empty
{
  callback(null, "error");

}).finally(function()
{
  if(connection) // CLEAN
  {
    connection.releaseConnection(connection)
    connection.end();
  }
});
CodeFoodPixels commented 7 years ago

Thanks for reporting! I'll have a look into it when I get a chance. :+1:

CodeFoodPixels commented 7 years ago

@NemOry Having had a chance to try this, it's failing as expected and I can't replicate your bug. If I do a console.log(error) inside the .catch it logs out the error and a stack trace.

oliverbytes commented 7 years ago

Hi Luke,

You're right. It works now in my side too. It was weird the other day. I'll report again whenever I find another issue. Thanks a lot for this great library. It's really useful for me and to everybody else...