14. API: Errors
See Error Handling for usage information.
14.1. Error Properties
The Error object contains code
, errorNum
, message
, offset
,
and stack
properties.
- error.code
Added in version 6.0.
This property is a string that represents the error code, which is the error prefix followed by the error number, for example
ORA-01017
,DPI-1080
, andNJS-500
.
- error.errorNum
This property is a number which represents the Oracle error number. This value is undefined for non-Oracle errors and for messages prefixed with NJS or DPI.
- error.message
This property is a string which represents the text of the error message.
The error may be a standard Oracle message with a prefix like ORA or PLS. Alternatively, it may be a node-oracledb specific error prefixed with NJS or DPI.
A single line error message may look like this:
ORA-01017: invalid username/password; logon denied
A multi-line error message may look like this:
ORA-06550: line 1, column 7: PLS-00201: identifier 'TESTPRC' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored
- error.offset
This property is a number and it is the character offset into the SQL text that resulted in the Oracle error. The value may be
0
in non-SQL contexts. This value is undefined for non-Oracle errors and for messages prefixed with NJS or DPI.When batchErrors mode in
connection.executeMany()
returns an array of Error objects in the callback result parameter, eachoffset
property is a zero-based index corresponding to theexecuteMany()
binds parameter array, indicating which record could not be processed. See Handling Data Errors. In node-oracledb 4.2, the maximumoffset
value was changed from (2^16)-1 to (2^32)-1.
- error.stack
This property is a string. When using Promises or Async/Await, the Error object includes a stack trace, for example:
Error: ORA-00942: table or view does not exist at async Object.myDoQuery (/Users/cjones/db.js:5:20) at async run (/Users/cjones/test.js:51:14)}
The stack trace displays only the application backtrace and not the driver’s internal frames or functions.
See Increasing the Stack Trace Limit to understand how to increase the number of stack frames displayed in a trace.