You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if there is no MySQL server running on localhost, connection.connect(); will get ECONNREFUSED, however, there is no callback given to it, to get the error and reject the promise.
sequelize for example lets you handle connections errors this way:
sequelize.authenticate().then(()=>{console.log('Connection has been established successfully.');}).catch(err=>{console.error('Unable to connect to the database:',err);});
maybe we can expose the createDb function instead of executing it automatically, and allow the user to catch connection errors that way ?
varnest=require('Tayr');varT=newnest({host: 'localhost',database: 'databaseName'});// createDb is not called automatically, so no exception is raisedT.createDb().then(()=>{// database is ready}).catch((err)=>{//err can be ECONNREFUSED})
another example is on line 497, if (err) throw err; will either crash the node process or keep the promise in pending state indefinitely.
Instead, something like if (err) return reject(err); would be more appropriate. The goal here is to allow catching and handling of errors in user code.
I also think that the onReject method is not very helpful, instead, I would prefer if errors would be handlable using a .catch in user code.
The text was updated successfully, but these errors were encountered:
hi,
I really like redbeanphp, and finding your library made me excited, however before I can use it, I see a few problems.
first one is I don't see any way to handle errors. The most basic example being:
if there is no MySQL server running on localhost,
connection.connect();
will getECONNREFUSED
, however, there is no callback given to it, to get the error and reject the promise.sequelize for example lets you handle connections errors this way:
maybe we can expose the
createDb
function instead of executing it automatically, and allow the user to catch connection errors that way ?another example is on line 497,
if (err) throw err;
will either crash the node process or keep the promise in pending state indefinitely.Instead, something like
if (err) return reject(err);
would be more appropriate. The goal here is to allow catching and handling of errors in user code.I also think that the
onReject
method is not very helpful, instead, I would prefer if errors would be handlable using a.catch
in user code.The text was updated successfully, but these errors were encountered: