Reputation: 183
How to get error message from "err" variable? When I dump that variable it contains
{ [Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: _test.Id] errno: 19, code: 'SQLITE_CONSTRAINT' }
I need to get "Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: _test.Id" from "err" variable. I'm executing this query.
db.run("INSERT INTO _test (Var1) VALUES (?)", '1', function (err) {
if (err) {
console.log(err);
return;
}
});
Alredy tried err[0], print out all properties with "for", but it returns only "errorno" and "code" properties.
Upvotes: 2
Views: 3795
Reputation: 9807
It's an exception object in JS. The message is stored in err.message
. The console just prints out those square brackets when serializing objects; it's not an array.
Upvotes: 2