mardi 6 octobre 2015

Error handling in node-sqlite3

How do I handle error in sqlite3? For example, I have this simple code:

var stmt = db.prepare("update Tickets set " + columns + " where id = (?)");
stmt.run(req.body.id);
stmt.finalize();

db.close();

All four functions prepare, run, finalize, close has the potential to throw error. This is on my express.js server so I'm trying to put a res.error() statement somewhere to return result. I don't want to put it in all of them because I can run into a multiple res.setHeader error.

Is there a document on error handling practice with sqlite3? I can't find it in its API documentation.

Aucun commentaire:

Enregistrer un commentaire