I follow a simple try … catch pattern for my SQLite queries
try {
… run query and get result …
}
catch (error) {
console.log(error);
}
On error, I get a nice stacktrace like this
SqliteError: no such column:
at getData (/Users/punkish/Projects/zenodeo/bin/facets.js:8:25)
at Object.<anonymous> (/Users/punkish/Projects/zenodeo/bin/facets.js:23:1)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
I've written my own small logging routine so I can embellish the messages with colors (using chalk) and some extra info I find helpful, now I have
try {
… run query and get result …
}
catch (error) {
mylogger(error);
}
Except, now I just get the following
SqliteError: no such column:
And no, the mylogger is not eating/chopping away the extra bits. I've added the following to it
if (typeof error === 'object') {
log('type: object');
log(`error: ${JSON.stringify(error)}`)
}
and I get
type: object
error: SqliteError: no such column:
Seems like the stacktrace is streaming, and all of it doesn't go to mylogger. In any case, how can I get all of it?