Node mssql complete stacktrace

84 Views Asked by At

Why don't i get a stacktrace pointing to the excution point of my file

const sqlSelect = "error";
 
const result = await sql.query(sqlSelect);

result:

    err = new RequestError(err, 'EREQUEST')
          ^

RequestError: Could not find stored procedure 'error'.
    at handleError (...\node_modules\mssql\lib\tedious\request.js:384:15)
    at Connection.emit (node:events:513:28)
    at Connection.emit (..\node_modules\tedious\lib\connection.js:1048:18)
    at RequestTokenHandler.onErrorMessage (...\node_modules\tedious\lib\token\handler.js:365:21)
    at Readable.<anonymous> (...\node_modules\tedious\lib\token\token-stream-parser.js:26:33)
    at Readable.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at next (node:internal/streams/from:98:31) {
1

There are 1 best solutions below

0
lars1595 On

Found this in the documentation

IMPORTANT: Always attach an error listener to created connection. Whenever something goes wrong with the connection it will emit an error and if there is no listener it will crash your application with an uncaught error.

So i did a general

process.on('uncaughtException', (err) => {
  //Error handeling
});