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.
Take a look at the api. Each of those functions takes a callback, whose first parameter is an error.
This will help you handle an error, but it will not stop your app from crashing.  In order to stop a crash, you'll have to use a try/catch , or preferably learn how to use domains.
Errors are emitted on "error" event. you may want to try doing something like below after you initialise your db handle.
db.on("error", function(error) {
    console.log("Getting an error : ", error);
}); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With