Vote count:
0
Building an app with Nodejs, Express and MySQL. I have decided to use the 'mysql' library found in NPM at this link: http://ift.tt/1BuU979.
While testing I purposely created a duplicate entry condition that violated a unique constraint because I wanted to see what the returned error object looks like.
When I console.log(error) from the query the following is what prints:
{ [Error: ER_DUP_ENTRY: Duplicate entry 'abcdefg' for key 'token_UNIQUE'] code: 'ER_DUP_ENTRY', errno: 1062, sqlState: '23000', index: 0 }
I must be missing something obvious. But I cannot seem to access the data in that first array looking thing. The part of the object that starts with [Error: and ends with 'token_UNIQUE']
How do I access that part of the object? Thanks!
(also, first I thought it was an improperly formatted object string or something buggy from the mysql library but underscore.js says it is an object
_.isObject(error); //true
How do I access this Javascript mysql error object (Nodejs)?
Aucun commentaire:
Enregistrer un commentaire