console.log outputs it like this,
{ [error: syntax error at or near "step"]
length: 86,
name: 'error',
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '62',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
file: 'scan.l',
line: '1001',
routine: 'scanner_yyerror' }
but JSON.stringify doesn't sees the narrative part of an error,
{"length":86,"name":"error","severity":"ERROR","code":"42601","position":"62","file":"scan.l","line":"1001","routine":"scanner_yyerror"}
I can't figure out how to get this "error: column "undefined" does not exist" reading wikies (https://github.com/brianc/node-postgres/wiki/Error-handling, http://nodejs.ru/doc/v0.4.x/stdio.html#console.log)
The code is like this,
client.query(selstring, function(err, result) {
if(err){
res.send(JSON.stringify(err));
console.log(err);
}else{
thanks
UPDATE: err.toString()
shows error: syntax error at or near "step"
selstring
. – robertklep Feb 27 '13 at 13:19select max(date)::character varying dt from calendar where11 step=0
. my task is to get the error description. the query is intentionally wrong – fedd Feb 27 '13 at 13:24err.toString()
return? – robertklep Feb 27 '13 at 13:24toString
(EDIT:err.message
is much cleaner) – robertklep Feb 27 '13 at 14:21toJSON
method to decide for itself what will be returned when you callJSON.stringify()
on its instances. Here's an example: jsfiddle.net/QmWfq – robertklep Feb 27 '13 at 14:33