oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.26k stars 1.07k forks source link

Can not get all values in the error object #1456

Closed haarse closed 2 years ago

haarse commented 2 years ago

I'm trying to write the eventually Oracle error I get to a file. But when using JSON.stringify(err), the properties message and stack seems to be non-enumerable. I found it impossible to save these two properties and write them out. Is this true? I'm using Typescript, but I don't think that is the problem.

`try { connection = await oracledb.getConnection( { user : "hr", password : mypw, connectString : "localhost/XEPDB1" });

const result = await connection.execute(
  `SELECT qwerty
   FROM departments
   WHERE manager_id = :id`,
  [103],  // bind value for :id
);
console.log(result.rows);

} catch (err) { console.log(JSON.stringify(err)); console.error(err); } finally { }`

You can see the difference in the two console functions result. Can I get the values it in some other way?

haarse commented 2 years ago

image

The faded font for properties message and stack means that the properties are non-enumerable. /Håkan

cjbj commented 2 years ago

This isn't specific to node-oracledb:

let x = new Error('abc');
console.log(x.propertyIsEnumerable('message'));  // false
haarse commented 2 years ago

Ok, thanks. I missed to check that.

cjbj commented 2 years ago

Comments, ideas and suggestions for improving error messages are welcome. (In particular I'd love to see a PR to print the error stack better, see https://github.com/oracle/node-oracledb/issues/465)

stale[bot] commented 2 years ago

This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically closed because it has not been updated for a month.