1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | 'use strict';
|
28 |
|
29 | const util = require('util');
|
30 |
|
31 |
|
32 | const ERR_PREFIX = "NJS";
|
33 |
|
34 |
|
35 | const ERR_INVALID_POOL = 2;
|
36 | const ERR_INVALID_CONNECTION = 3;
|
37 | const ERR_INVALID_PROPERTY_VALUE = 4;
|
38 | const ERR_INVALID_PARAMETER_VALUE = 5;
|
39 | const ERR_INVALID_PROPERTY_VALUE_IN_PARAM = 7;
|
40 | const ERR_INVALID_NUMBER_OF_PARAMETERS = 9;
|
41 | const ERR_UNSUPPORTED_DATA_TYPE = 10;
|
42 | const ERR_BIND_VALUE_AND_TYPE_MISMATCH = 11;
|
43 | const ERR_INVALID_BIND_DATA_TYPE = 12;
|
44 | const ERR_INVALID_BIND_DIRECTION = 13;
|
45 | const ERR_NO_TYPE_FOR_CONVERSION = 15;
|
46 | const ERR_INSUFFICIENT_BUFFER_FOR_BINDS = 16;
|
47 | const ERR_BUSY_RS = 17;
|
48 | const ERR_INVALID_RS = 18;
|
49 | const ERR_NOT_A_QUERY = 19;
|
50 | const ERR_INVALID_TYPE_FOR_CONVERSION = 21;
|
51 | const ERR_INVALID_LOB = 22;
|
52 | const ERR_BUSY_LOB = 23;
|
53 | const ERR_INSUFFICIENT_MEMORY = 24;
|
54 | const ERR_INVALID_TYPE_FOR_ARRAY_BIND = 34;
|
55 | const ERR_REQUIRED_MAX_ARRAY_SIZE = 35;
|
56 | const ERR_INVALID_ARRAY_SIZE = 36;
|
57 | const ERR_INCOMPATIBLE_TYPE_ARRAY_BIND = 37;
|
58 | const ERR_CONN_REQUEST_TIMEOUT = 40;
|
59 | const ERR_CANNOT_CONVERT_RS_TO_STREAM = 41;
|
60 | const ERR_CANNOT_INVOKE_RS_METHODS = 42;
|
61 | const ERR_RS_ALREADY_CONVERTED = 43;
|
62 | const ERR_INVALID_BIND_UNIT = 44;
|
63 | const ERR_CANNOT_LOAD_BINARY = 45;
|
64 | const ERR_POOL_WITH_ALIAS_ALREADY_EXISTS = 46;
|
65 | const ERR_POOL_WITH_ALIAS_NOT_FOUND = 47;
|
66 | const ERR_INCOMPATIBLE_TYPE_ARRAY_INDEX_BIND = 52;
|
67 | const ERR_MIXED_BIND = 55;
|
68 | const ERR_MISSING_MAX_SIZE_BY_POS = 56;
|
69 | const ERR_MISSING_MAX_SIZE_BY_NAME = 57;
|
70 | const ERR_MAX_SIZE_TOO_SMALL = 58;
|
71 | const ERR_MISSING_TYPE_BY_POS = 59;
|
72 | const ERR_MISSING_TYPE_BY_NAME = 60;
|
73 | const ERR_INVALID_SUBSCR = 61;
|
74 | const ERR_MISSING_SUBSCR_CALLBACK = 62;
|
75 | const ERR_MISSING_SUBSCR_SQL = 63;
|
76 | const ERR_POOL_CLOSING = 64;
|
77 | const ERR_POOL_CLOSED = 65;
|
78 | const ERR_INVALID_SODA_DOC_CURSOR = 66;
|
79 | const ERR_NO_BINARY_AVAILABLE = 67;
|
80 | const ERR_INVALID_ERR_NUM = 68;
|
81 | const ERR_NODE_TOO_OLD = 69;
|
82 | const ERR_INVALID_AQ_MESSAGE = 70;
|
83 | const ERR_DBL_CONNECT_STRING = 75;
|
84 | const ERR_QUEUE_MAX_EXCEEDED = 76;
|
85 | const ERR_UNSUPPORTED_DATA_TYPE_IN_JSON = 78;
|
86 | const ERR_DBL_USER = 80;
|
87 | const ERR_CONCURRENT_OPS = 81;
|
88 | const ERR_POOL_RECONFIGURING = 82;
|
89 | const ERR_POOL_STATISTICS_DISABLED = 83;
|
90 | const ERR_TOKEN_BASED_AUTH = 84;
|
91 | const ERR_POOL_TOKEN_BASED_AUTH = 85;
|
92 | const ERR_CONN_TOKEN_BASED_AUTH = 86;
|
93 | const ERR_TOKEN_HAS_EXPIRED = 87;
|
94 | const ERR_NOT_IMPLEMENTED = 89;
|
95 | const ERR_INIT_ORACLE_CLIENT_ARGS = 90;
|
96 | const ERR_MISSING_FILE = 91;
|
97 | const ERR_INVALID_NUMBER_OF_CONNECTIONS = 92;
|
98 | const ERR_EXEC_MODE_ONLY_FOR_DML = 95;
|
99 | const ERR_INVALID_BIND_NAME = 97;
|
100 | const ERR_WRONG_NUMBER_OF_POSITIONAL_BINDS = 98;
|
101 | const ERR_BUFFER_LENGTH_INSUFFICIENT = 99;
|
102 | const ERR_NCHAR_CS_NOT_SUPPORTED = 100;
|
103 | const ERR_MISSING_CREDENTIALS = 101;
|
104 | const ERR_UNEXPECTED_END_OF_DATA = 102;
|
105 | const ERR_UNEXPECTED_MESSAGE_TYPE = 103;
|
106 | const ERR_POOL_HAS_BUSY_CONNECTIONS = 104;
|
107 | const ERR_NAN_VALUE = 105;
|
108 | const ERR_INTERNAL = 106;
|
109 | const ERR_INVALID_REF_CURSOR = 107;
|
110 | const ERR_INVALID_TYPE_NUM = 109;
|
111 | const ERR_INVALID_ORACLE_TYPE_NUM = 110;
|
112 | const ERR_UNEXPECTED_NEGATIVE_INTEGER = 111;
|
113 | const ERR_INTEGER_TOO_LARGE = 112;
|
114 | const ERR_UNEXPECTED_DATA = 113;
|
115 | const ERR_OSON_FIELD_NAME_LIMITATION = 114;
|
116 | const ERR_ORACLE_NUMBER_NO_REPR = 115;
|
117 | const ERR_UNSUPPORTED_VERIFIER_TYPE = 116;
|
118 | const ERR_THIN_CONNECTION_ALREADY_CREATED = 118;
|
119 | const ERR_UNSUPPORTED_CONVERSION = 119;
|
120 | const ERR_FETCH_TYPE_HANDLER_RETURN_VALUE = 120;
|
121 | const ERR_FETCH_TYPE_HANDLER_TYPE = 121;
|
122 | const ERR_FETCH_TYPE_HANDLER_CONVERTER = 122;
|
123 | const ERR_CALL_TIMEOUT_EXCEEDED = 123;
|
124 | const ERR_EMPTY_CONNECT_STRING = 125;
|
125 | const ERR_OSON_VERSION_NOT_SUPPORTED = 126;
|
126 | const ERR_UNKOWN_SERVER_SIDE_PIGGYBACK = 127;
|
127 | const ERR_UNKNOWN_COLUMN_TYPE_NAME = 128;
|
128 | const ERR_INVALID_OBJECT_TYPE_NAME = 129;
|
129 | const ERR_TDS_TYPE_NOT_SUPPORTED = 130;
|
130 | const ERR_INVALID_COLL_INDEX_SET = 131;
|
131 | const ERR_INVALID_COLL_INDEX_GET = 132;
|
132 | const ERR_DELETE_ELEMENTS_OF_VARRAY = 133;
|
133 | const ERR_WRONG_VALUE_FOR_DBOBJECT_ATTR = 134;
|
134 | const ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM = 135;
|
135 | const ERR_WRONG_CRED_FOR_EXTAUTH = 136;
|
136 | const ERR_MISSING_BIND_VALUE = 137;
|
137 | const ERR_SERVER_VERSION_NOT_SUPPORTED = 138;
|
138 | const ERR_UNEXPECTED_XML_TYPE = 139;
|
139 | const ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY = 140;
|
140 | const ERR_TOO_MANY_BATCH_ERRORS = 141;
|
141 | const ERR_WRONG_LENGTH_FOR_DBOBJECT_ATTR = 142;
|
142 | const ERR_WRONG_LENGTH_FOR_DBOBJECT_ELEM = 143;
|
143 | const ERR_VECTOR_FORMAT_NOT_SUPPORTED = 144;
|
144 | const ERR_VECTOR_VERSION_NOT_SUPPORTED = 145;
|
145 | const ERR_OBJECT_IS_NOT_A_COLLECTION = 146;
|
146 |
|
147 |
|
148 | const ERR_CONNECTION_CLOSED = 500;
|
149 | const ERR_CONNECTION_LOSTCONTACT = 501;
|
150 | const ERR_CONNECTION_INCOMPLETE = 503;
|
151 | const ERR_PROXY_CONNECTION_FAILURE = 504;
|
152 | const ERR_TLS_INIT_FAILURE = 505;
|
153 | const ERR_TLS_AUTH_FAILURE = 506;
|
154 | const ERR_TLS_DNMATCH_FAILURE = 507;
|
155 | const ERR_TLS_HOSTMATCH_FAILURE = 508;
|
156 | const ERR_INVALID_PACKET = 509;
|
157 | const ERR_CONNECTION_TIMEDOUT = 510;
|
158 | const ERR_CONNECTION_REFUSED = 511;
|
159 | const ERR_INVALID_CONNECT_STRING_PARAMETERS = 512;
|
160 | const ERR_CONNECTION_INBAND = 513;
|
161 | const ERR_INVALID_CONNECT_STRING_SYNTAX = 514;
|
162 | const ERR_INVALID_EZCONNECT_SYNTAX = 515;
|
163 | const ERR_NO_CONFIG_DIR = 516;
|
164 | const ERR_TNS_ENTRY_NOT_FOUND = 517;
|
165 | const ERR_INVALID_SERVICE_NAME = 518;
|
166 | const ERR_INVALID_SID = 519;
|
167 | const ERR_TNS_NAMES_FILE_MISSING = 520;
|
168 | const ERR_CONNECTION_EOF = 521;
|
169 |
|
170 |
|
171 | const WRN_COMPILATION_CREATE = 700;
|
172 |
|
173 |
|
174 |
|
175 | const adjustErrorXref = new Map();
|
176 | adjustErrorXref.set("DPI-1010", ERR_INVALID_CONNECTION);
|
177 | adjustErrorXref.set("DPI-1024", [ERR_INVALID_COLL_INDEX_GET, 'at index ([0-9]+) does']);
|
178 | adjustErrorXref.set("DPI-1044", ERR_ORACLE_NUMBER_NO_REPR);
|
179 | adjustErrorXref.set("DPI-1055", ERR_NAN_VALUE);
|
180 | adjustErrorXref.set("DPI-1063", ERR_EXEC_MODE_ONLY_FOR_DML);
|
181 | adjustErrorXref.set("DPI-1067", [ERR_CALL_TIMEOUT_EXCEEDED, "call timeout of ([0-9]+) ms"]);
|
182 | adjustErrorXref.set("DPI-1080", ERR_CONNECTION_CLOSED);
|
183 | adjustErrorXref.set("OCI-22303", [ERR_INVALID_OBJECT_TYPE_NAME, 'type "([^"]*"."[^"]*)"']);
|
184 | adjustErrorXref.set("OCI-22164", ERR_DELETE_ELEMENTS_OF_VARRAY);
|
185 | adjustErrorXref.set("OCI-22165", [ERR_INVALID_COLL_INDEX_SET, /index \[([0-9]+)\] must be in the range of \[([0-9]+)\] to \[([0-9]+)\]/]);
|
186 | adjustErrorXref.set("ORA-00028", ERR_CONNECTION_CLOSED);
|
187 | adjustErrorXref.set("ORA-00600", ERR_CONNECTION_CLOSED);
|
188 | adjustErrorXref.set("ORA-24338", ERR_INVALID_REF_CURSOR);
|
189 | adjustErrorXref.set("ORA-25708", ERR_TOKEN_HAS_EXPIRED);
|
190 | adjustErrorXref.set("ORA-24344", WRN_COMPILATION_CREATE);
|
191 |
|
192 |
|
193 | const messages = new Map();
|
194 | messages.set(ERR_INVALID_POOL,
|
195 | 'invalid pool');
|
196 | messages.set(ERR_INVALID_CONNECTION,
|
197 | 'invalid or closed connection');
|
198 | messages.set(ERR_INVALID_PROPERTY_VALUE,
|
199 | 'invalid value for property "%s"');
|
200 | messages.set(ERR_INVALID_PARAMETER_VALUE,
|
201 | 'invalid value for parameter %d');
|
202 | messages.set(ERR_INVALID_PROPERTY_VALUE_IN_PARAM,
|
203 | 'invalid value for "%s" in parameter %d');
|
204 | messages.set(ERR_INVALID_NUMBER_OF_PARAMETERS,
|
205 | 'invalid number of parameters');
|
206 |
|
207 | messages.set(ERR_UNSUPPORTED_DATA_TYPE,
|
208 | 'unsupported data type %d in column %d');
|
209 | messages.set(ERR_BIND_VALUE_AND_TYPE_MISMATCH,
|
210 | 'encountered bind value and type mismatch');
|
211 | messages.set(ERR_INVALID_BIND_DATA_TYPE,
|
212 | 'encountered invalid bind data type in parameter %d');
|
213 | messages.set(ERR_INVALID_BIND_DIRECTION,
|
214 | 'invalid bind direction');
|
215 | messages.set(ERR_NO_TYPE_FOR_CONVERSION,
|
216 | 'type was not specified for conversion');
|
217 |
|
218 | messages.set(ERR_INSUFFICIENT_BUFFER_FOR_BINDS,
|
219 | 'buffer is too small for OUT binds');
|
220 | messages.set(ERR_BUSY_RS,
|
221 | 'concurrent operations on ResultSet are not allowed');
|
222 | messages.set(ERR_INVALID_RS,
|
223 | 'invalid ResultSet');
|
224 | messages.set(ERR_NOT_A_QUERY,
|
225 | 'ResultSet cannot be returned for non-query statements');
|
226 | messages.set(ERR_INVALID_TYPE_FOR_CONVERSION,
|
227 | 'invalid type for conversion specified');
|
228 | messages.set(ERR_INVALID_LOB,
|
229 | 'invalid Lob');
|
230 | messages.set(ERR_BUSY_LOB,
|
231 | 'concurrent operations on a Lob are not allowed');
|
232 |
|
233 | messages.set(ERR_INSUFFICIENT_MEMORY,
|
234 | 'memory allocation failed');
|
235 | messages.set(ERR_INVALID_TYPE_FOR_ARRAY_BIND,
|
236 | 'data type is unsupported for array bind');
|
237 | messages.set(ERR_REQUIRED_MAX_ARRAY_SIZE,
|
238 | 'maxArraySize is required for IN OUT array bind');
|
239 | messages.set(ERR_INVALID_ARRAY_SIZE,
|
240 | 'length of given array is greater than "maxArraySize"');
|
241 | messages.set(ERR_INCOMPATIBLE_TYPE_ARRAY_BIND,
|
242 | 'invalid data type at array index %d for bind ":%s"');
|
243 | messages.set(ERR_CONN_REQUEST_TIMEOUT,
|
244 | 'connection request timeout. Request exceeded "queueTimeout" of %d');
|
245 | messages.set(ERR_CANNOT_CONVERT_RS_TO_STREAM,
|
246 | 'cannot convert ResultSet to QueryStream after invoking methods');
|
247 | messages.set(ERR_CANNOT_INVOKE_RS_METHODS,
|
248 | 'cannot invoke ResultSet methods after converting to QueryStream');
|
249 | messages.set(ERR_RS_ALREADY_CONVERTED,
|
250 | 'ResultSet already converted to QueryStream');
|
251 | messages.set(ERR_INVALID_BIND_UNIT,
|
252 | 'bind object must contain one of the following attributes: "dir", "type", "maxSize", or "val"');
|
253 | messages.set(ERR_CANNOT_LOAD_BINARY,
|
254 | 'cannot load a node-oracledb Thick mode binary for Node.js. Please try using Thin mode. %s');
|
255 | messages.set(ERR_POOL_WITH_ALIAS_ALREADY_EXISTS,
|
256 | 'pool alias "%s" already exists in the connection pool cache');
|
257 | messages.set(ERR_POOL_WITH_ALIAS_NOT_FOUND,
|
258 | 'pool alias "%s" not found in connection pool cache');
|
259 | messages.set(ERR_INCOMPATIBLE_TYPE_ARRAY_INDEX_BIND,
|
260 | 'invalid data type at array index %d for bind position %d');
|
261 | messages.set(ERR_MIXED_BIND,
|
262 | 'binding by position and name cannot be mixed');
|
263 | messages.set(ERR_MISSING_MAX_SIZE_BY_POS,
|
264 | 'maxSize for bind position %d must be specified and be greater than zero');
|
265 | messages.set(ERR_MISSING_MAX_SIZE_BY_NAME,
|
266 | 'maxSize for bind "%s" must be specified and greater than zero');
|
267 | messages.set(ERR_MAX_SIZE_TOO_SMALL,
|
268 | 'maxSize of %d is too small for value of length %d in row %d');
|
269 | messages.set(ERR_MISSING_TYPE_BY_POS,
|
270 | 'type must be specified for bind position %d');
|
271 | messages.set(ERR_MISSING_TYPE_BY_NAME,
|
272 | 'type must be specified for bind "%s"');
|
273 | messages.set(ERR_INVALID_SUBSCR,
|
274 | 'invalid subscription');
|
275 | messages.set(ERR_MISSING_SUBSCR_CALLBACK,
|
276 | 'subscription notification callback missing');
|
277 | messages.set(ERR_MISSING_SUBSCR_SQL,
|
278 | 'subscription notification SQL missing');
|
279 | messages.set(ERR_POOL_CLOSING,
|
280 | 'connection pool is closing');
|
281 | messages.set(ERR_POOL_CLOSED,
|
282 | 'connection pool was closed');
|
283 | messages.set(ERR_INVALID_SODA_DOC_CURSOR,
|
284 | 'invalid SODA document cursor');
|
285 | messages.set(ERR_NO_BINARY_AVAILABLE,
|
286 | 'a pre-built node-oracledb Thick mode binary was not found for %s');
|
287 | messages.set(ERR_INVALID_ERR_NUM,
|
288 | 'invalid error number %d supplied');
|
289 | messages.set(ERR_NODE_TOO_OLD,
|
290 | 'node-oracledb %s requires Node.js %s or later');
|
291 | messages.set(ERR_INVALID_AQ_MESSAGE,
|
292 | 'message must be a string, buffer, database object or an object containing a payload property which itself is a string, buffer or database object');
|
293 | messages.set(ERR_DBL_CONNECT_STRING,
|
294 | 'only one of "connectString" and "connectionString" can be used');
|
295 | messages.set(ERR_QUEUE_MAX_EXCEEDED,
|
296 | 'connection request rejected. Pool queue length "queueMax" %d reached');
|
297 |
|
298 | messages.set(ERR_UNSUPPORTED_DATA_TYPE_IN_JSON,
|
299 | 'unsupported data type %d in JSON value');
|
300 | messages.set(ERR_DBL_USER,
|
301 | 'only one of "user" and "username" can be used');
|
302 | messages.set(ERR_CONCURRENT_OPS,
|
303 | 'concurrent operations on a connection are disabled');
|
304 | messages.set(ERR_POOL_RECONFIGURING,
|
305 | 'connection pool is being reconfigured');
|
306 | messages.set(ERR_POOL_STATISTICS_DISABLED,
|
307 | 'pool statistics are not enabled');
|
308 | messages.set(ERR_TOKEN_BASED_AUTH,
|
309 | 'invalid access token');
|
310 | messages.set(ERR_POOL_TOKEN_BASED_AUTH,
|
311 | 'invalid connection pool configuration with token-based authentication. The "homogeneous" and "externalAuth" attributes must be set to true');
|
312 | messages.set(ERR_CONN_TOKEN_BASED_AUTH,
|
313 | 'invalid standalone configuration with token-based authentication. The "externalAuth" attribute must be set to true');
|
314 | messages.set(ERR_TOKEN_HAS_EXPIRED,
|
315 | 'access token has expired');
|
316 | messages.set(ERR_NOT_IMPLEMENTED,
|
317 | '%s is not supported by node-oracledb in Thin mode');
|
318 | messages.set(ERR_INIT_ORACLE_CLIENT_ARGS,
|
319 | 'initOracleClient() was already called with different arguments');
|
320 | messages.set(ERR_MISSING_FILE,
|
321 | 'file %s is missing');
|
322 | messages.set(ERR_INVALID_NUMBER_OF_CONNECTIONS,
|
323 | '"poolMax" %d must be greater than or equal to "poolMin" %d');
|
324 | messages.set(ERR_EXEC_MODE_ONLY_FOR_DML,
|
325 | 'setting "batchErrors" or "dmlRowCounts" to true is only permitted for DML statements');
|
326 | messages.set(ERR_INVALID_BIND_NAME,
|
327 | 'no bind placeholder named ":%s" was found in the statement text');
|
328 | messages.set(ERR_WRONG_NUMBER_OF_POSITIONAL_BINDS,
|
329 | '%s positional bind values are required but %s were provided');
|
330 | messages.set(ERR_BUFFER_LENGTH_INSUFFICIENT,
|
331 | 'internal error: buffer of length %s insufficient to hold %s bytes');
|
332 | messages.set(ERR_NCHAR_CS_NOT_SUPPORTED,
|
333 | 'national character set id %d is not supported by node-oracledb in Thin mode');
|
334 | messages.set(ERR_MISSING_CREDENTIALS,
|
335 | 'no credentials specified');
|
336 | messages.set(ERR_UNEXPECTED_END_OF_DATA,
|
337 | 'unexpected end of data: want %d bytes but only %d bytes are available');
|
338 | messages.set(ERR_UNEXPECTED_MESSAGE_TYPE,
|
339 | 'unexpected message type %d received at position %d of packet %d');
|
340 | messages.set(ERR_POOL_HAS_BUSY_CONNECTIONS,
|
341 | 'connection pool cannot be closed because connections are busy');
|
342 | messages.set(ERR_NAN_VALUE,
|
343 | 'value is not a number (NaN) and cannot be used in Oracle Database numbers');
|
344 | messages.set(ERR_INTERNAL,
|
345 | 'internal error: %s');
|
346 | messages.set(ERR_INVALID_REF_CURSOR,
|
347 | 'invalid cursor');
|
348 | messages.set(ERR_INVALID_TYPE_NUM,
|
349 | 'invalid type number %d');
|
350 | messages.set(ERR_INVALID_ORACLE_TYPE_NUM,
|
351 | 'invalid Oracle type number %d [csfrm: %d]');
|
352 | messages.set(ERR_UNEXPECTED_NEGATIVE_INTEGER,
|
353 | 'internal error: read a negative integer when expecting a positive integer at position %d of packet %d');
|
354 | messages.set(ERR_INTEGER_TOO_LARGE,
|
355 | 'internal error: read integer of length %d when expecting integer of no more than length %d at position %d of packet %d');
|
356 | messages.set(ERR_UNEXPECTED_DATA,
|
357 | 'unexpected data received: %s');
|
358 | messages.set(ERR_OSON_FIELD_NAME_LIMITATION,
|
359 | 'OSON field names may not exceed 255 UTF-8 encoded bytes');
|
360 | messages.set(ERR_ORACLE_NUMBER_NO_REPR,
|
361 | 'value cannot be represented as an Oracle Database number');
|
362 | messages.set(ERR_UNSUPPORTED_VERIFIER_TYPE,
|
363 | 'password verifier type 0x%s is not supported by node-oracledb in Thin mode');
|
364 | messages.set(ERR_THIN_CONNECTION_ALREADY_CREATED,
|
365 | 'node-oracledb Thick mode cannot be enabled because a Thin mode connection has already been created');
|
366 | messages.set(ERR_UNSUPPORTED_CONVERSION,
|
367 | 'conversion from type %s to type %s is not supported');
|
368 | messages.set(ERR_FETCH_TYPE_HANDLER_RETURN_VALUE,
|
369 | 'fetchTypeHandler return value must be an object');
|
370 | messages.set(ERR_FETCH_TYPE_HANDLER_TYPE,
|
371 | 'fetchTypeHandler return value attribute "type" must be a valid database type');
|
372 | messages.set(ERR_FETCH_TYPE_HANDLER_CONVERTER,
|
373 | 'fetchTypeHandler return value attribute "converter" must be a function');
|
374 | messages.set(ERR_CALL_TIMEOUT_EXCEEDED,
|
375 | 'call timeout of %d ms exceeded');
|
376 | messages.set(ERR_EMPTY_CONNECT_STRING,
|
377 | '"connectString" cannot be empty or undefined. Bequeath connections are not supported in Thin mode');
|
378 | messages.set(ERR_OSON_VERSION_NOT_SUPPORTED,
|
379 | 'OSON version %s is not supported');
|
380 | messages.set(ERR_UNKOWN_SERVER_SIDE_PIGGYBACK,
|
381 | 'internal error: unknown server side piggyback opcode %s');
|
382 | messages.set(ERR_UNKNOWN_COLUMN_TYPE_NAME,
|
383 | 'internal error: unknown column type name "%s"');
|
384 | messages.set(ERR_INVALID_OBJECT_TYPE_NAME,
|
385 | 'invalid object type name: "%s"');
|
386 | messages.set(ERR_TDS_TYPE_NOT_SUPPORTED,
|
387 | 'Oracle TDS data type %d is not supported');
|
388 | messages.set(ERR_INVALID_COLL_INDEX_SET,
|
389 | 'given index %d must be in the range of %d to %d');
|
390 | messages.set(ERR_INVALID_COLL_INDEX_GET,
|
391 | 'element at index %d does not exist');
|
392 | messages.set(ERR_DELETE_ELEMENTS_OF_VARRAY,
|
393 | 'cannot delete elements of a VARRAY');
|
394 | messages.set(ERR_WRONG_VALUE_FOR_DBOBJECT_ATTR,
|
395 | 'value is of wrong type for attribute %s of object %s');
|
396 | messages.set(ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM,
|
397 | 'value is of wrong type for an element of object %s');
|
398 | messages.set(ERR_WRONG_CRED_FOR_EXTAUTH,
|
399 | 'user name and password cannot be set when using external authentication');
|
400 | messages.set(ERR_MISSING_BIND_VALUE,
|
401 | 'a bind variable replacement value for placeholder ":%s" was not provided');
|
402 | messages.set(ERR_SERVER_VERSION_NOT_SUPPORTED,
|
403 | 'connections to this database server version are not supported by node-oracledb in Thin mode');
|
404 | messages.set(ERR_UNEXPECTED_XML_TYPE,
|
405 | 'unexpected XML type with flag %d');
|
406 | messages.set(ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY,
|
407 | 'user name must be enclosed in [] when using external authentication with a proxy user');
|
408 | messages.set(ERR_TOO_MANY_BATCH_ERRORS,
|
409 | 'the number of batch errors from executemany() exceeds 65535');
|
410 | messages.set(ERR_WRONG_LENGTH_FOR_DBOBJECT_ATTR,
|
411 | 'value too large for attribute %s of object %s (actual: %d, maximum: %d)');
|
412 | messages.set(ERR_WRONG_LENGTH_FOR_DBOBJECT_ELEM,
|
413 | 'value too large for element %d of object %s (actual: %d, maximum: %d)');
|
414 | messages.set(ERR_VECTOR_FORMAT_NOT_SUPPORTED,
|
415 | 'VECTOR format %d is not supported');
|
416 | messages.set(ERR_VECTOR_VERSION_NOT_SUPPORTED,
|
417 | 'VECTOR version %d is not supported');
|
418 | messages.set(ERR_OBJECT_IS_NOT_A_COLLECTION,
|
419 | 'object %s is not a collection');
|
420 |
|
421 |
|
422 |
|
423 | messages.set(ERR_CONNECTION_CLOSED,
|
424 | 'connection to the Oracle Database was broken');
|
425 | messages.set(ERR_CONNECTION_LOSTCONTACT,
|
426 | 'connection to host %s port %d terminated unexpectedly. (CONNECTION_ID=%s)\n%s');
|
427 | messages.set(ERR_CONNECTION_INCOMPLETE,
|
428 | 'connection to host %s port %d could not be established. (CONNECTION_ID=%s)\n%s');
|
429 | messages.set(ERR_PROXY_CONNECTION_FAILURE,
|
430 | 'connection establishment through a web proxy at host %s port %d failed. (CONNECTION_ID=%s)\n%s');
|
431 | messages.set(ERR_TLS_INIT_FAILURE,
|
432 | 'unable to initiate TLS connection. Please check if wallet credentials are valid');
|
433 | messages.set(ERR_TLS_AUTH_FAILURE,
|
434 | 'connection to host %s port %d encountered TLS handshake failure. (CONNECTION_ID=%s)\n%s');
|
435 | messages.set(ERR_TLS_DNMATCH_FAILURE,
|
436 | 'TLS detected an invalid certificate. Server DN in certificate does not match the specified DN');
|
437 | messages.set(ERR_TLS_HOSTMATCH_FAILURE,
|
438 | 'TLS detected an invalid certificate. %s not present in certificate');
|
439 | messages.set(ERR_INVALID_PACKET,
|
440 | 'internal error: invalid packet type or malformed packet received');
|
441 | messages.set(ERR_CONNECTION_TIMEDOUT,
|
442 | 'connection to host %s port %d timed out. Request exceeded "%s" of %d seconds. (CONNECTION_ID=%s)');
|
443 | messages.set(ERR_CONNECTION_REFUSED,
|
444 | 'connection to listener at host %s port %d was refused. (CONNECTION_ID=%s)\nCause: %s');
|
445 | messages.set(ERR_INVALID_CONNECT_STRING_PARAMETERS,
|
446 | 'invalid connection string parameters.\n%s');
|
447 | messages.set(ERR_CONNECTION_INBAND,
|
448 | 'error received through in-band notification: %s');
|
449 | messages.set(ERR_INVALID_CONNECT_STRING_SYNTAX,
|
450 | 'syntax error in connection string');
|
451 | messages.set(ERR_INVALID_EZCONNECT_SYNTAX,
|
452 | 'error in Easy Connect connection string: %s: %s');
|
453 | messages.set(ERR_NO_CONFIG_DIR,
|
454 | 'no configuration directory set or available to search for tnsnames.ora');
|
455 | messages.set(ERR_TNS_ENTRY_NOT_FOUND,
|
456 | 'cannot connect to Oracle Database. Unable to find "%s" in "%s"');
|
457 | messages.set(ERR_INVALID_SERVICE_NAME,
|
458 | 'cannot connect to Oracle Database. Service "%s" is not registered with the listener at host %s port %s. (CONNECTION_ID=%s)');
|
459 | messages.set(ERR_INVALID_SID,
|
460 | 'cannot connect to Oracle Database. SID "%s" is not registered with the listener at host %s port %s. (CONNECTION_ID=%s)');
|
461 | messages.set(ERR_TNS_NAMES_FILE_MISSING,
|
462 | 'cannot connect to Oracle Database. File tnsnames.ora not found in %s');
|
463 | messages.set(ERR_CONNECTION_EOF,
|
464 | 'connection to host %s port %d received end-of-file on communication channel. (CONNECTION_ID=%s)');
|
465 |
|
466 |
|
467 |
|
468 | messages.set(WRN_COMPILATION_CREATE,
|
469 | 'creation succeeded with compilation errors');
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | function assert(condition) {
|
478 | if (!condition) {
|
479 | const args = Array.prototype.slice.call(arguments, 1);
|
480 | throwErr(...args);
|
481 | }
|
482 | }
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 | function assertArgCount(args, minArgCount, maxArgCount) {
|
491 | assert(args.length >= minArgCount && args.length <= maxArgCount,
|
492 | ERR_INVALID_NUMBER_OF_PARAMETERS);
|
493 | }
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 | function assertParamPropBool(obj, parameterNum, propName) {
|
502 | if (obj[propName] !== undefined) {
|
503 | assertParamPropValue(typeof obj[propName] === 'boolean', parameterNum,
|
504 | propName);
|
505 | }
|
506 | }
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 | function assertParamPropFunction(obj, parameterNum, propName) {
|
514 | if (obj[propName] !== undefined) {
|
515 | assertParamPropValue(typeof obj[propName] === 'function', parameterNum,
|
516 | propName);
|
517 | }
|
518 | }
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 | function assertParamPropInt(obj, parameterNum, propName) {
|
527 | if (obj[propName] !== undefined) {
|
528 | assertParamPropValue(Number.isInteger(obj[propName]), parameterNum,
|
529 | propName);
|
530 | }
|
531 | }
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 | function assertParamPropUnsignedInt(obj, parameterNum, propName) {
|
540 | if (obj[propName] !== undefined) {
|
541 | assertParamPropValue(Number.isInteger(obj[propName]) && obj[propName] >= 0,
|
542 | parameterNum, propName);
|
543 | }
|
544 | }
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 | function assertParamPropString(obj, parameterNum, propName) {
|
552 | if (obj[propName] !== undefined) {
|
553 | assertParamPropValue(typeof obj[propName] === 'string', parameterNum,
|
554 | propName);
|
555 | }
|
556 | }
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 | function assertParamPropValue(condition, parameterNum, propName) {
|
565 | assert(condition, ERR_INVALID_PROPERTY_VALUE_IN_PARAM, propName,
|
566 | parameterNum);
|
567 | }
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 | function assertParamValue(condition, parameterNum) {
|
575 | assert(condition, ERR_INVALID_PARAMETER_VALUE, parameterNum);
|
576 | }
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 | function assertPropValue(condition, propName) {
|
584 | assert(condition, ERR_INVALID_PROPERTY_VALUE, propName);
|
585 | }
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 | function getErr(errorNum) {
|
594 | let baseText = messages.get(errorNum);
|
595 | let args = [...arguments];
|
596 | if (!baseText) {
|
597 | args = [undefined, errorNum];
|
598 | errorNum = ERR_INVALID_ERR_NUM;
|
599 | baseText = messages.get(errorNum);
|
600 | }
|
601 | const errorNumStr = errorNum.toString().padStart(3, '0');
|
602 | const code = `${ERR_PREFIX}-${errorNumStr}`;
|
603 | args[0] = `${code}: ${baseText}`;
|
604 | const err = new Error(util.format(...args));
|
605 | err.code = code;
|
606 | Error.captureStackTrace(err, getErr);
|
607 | return err;
|
608 | }
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 | function throwErr() {
|
617 | throw (getErr(...arguments));
|
618 | }
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 | function throwNotImplemented(feature) {
|
626 | throwErr(ERR_NOT_IMPLEMENTED, feature);
|
627 | }
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 | function transformErr(err, fnOpt) {
|
636 | if (!err.code) {
|
637 | const pos = err.message.indexOf(":");
|
638 | if (pos > 0) {
|
639 | err.code = err.message.substr(0, pos);
|
640 | |
641 |
|
642 |
|
643 |
|
644 | const settings = require('./settings.js');
|
645 | if (err.errorNum && settings.thin) {
|
646 | err.message += '\n' + 'Help: https://docs.oracle.com/error-help/db/ora-' +
|
647 | `${err.errorNum.toString().padStart(5, '0')}/`;
|
648 | }
|
649 | if (adjustErrorXref.has(err.code)) {
|
650 | let args = [];
|
651 | let driverErrorNum;
|
652 | const driverErrorInfo = adjustErrorXref.get(err.code);
|
653 | if (typeof driverErrorInfo === 'number') {
|
654 | driverErrorNum = driverErrorInfo;
|
655 | } else {
|
656 | driverErrorNum = driverErrorInfo[0];
|
657 | const pattern = driverErrorInfo[1];
|
658 | const results = err.message.match(pattern);
|
659 | if (results) {
|
660 | args = results.slice(1);
|
661 | }
|
662 | }
|
663 | const newErr = getErr(driverErrorNum, ...args);
|
664 | err.code = newErr.code;
|
665 | err.message = newErr.message + "\n" + err.message;
|
666 | }
|
667 | }
|
668 | }
|
669 |
|
670 | if (err.requiresStackCapture) {
|
671 | delete err.requiresStackCapture;
|
672 | Error.captureStackTrace(err, fnOpt);
|
673 | }
|
674 | return err;
|
675 | }
|
676 |
|
677 |
|
678 | module.exports = {
|
679 | ERR_INVALID_POOL,
|
680 | ERR_INVALID_CONNECTION,
|
681 | ERR_INVALID_PROPERTY_VALUE,
|
682 | ERR_INVALID_PARAMETER_VALUE,
|
683 | ERR_INVALID_PROPERTY_VALUE_IN_PARAM,
|
684 | ERR_INVALID_NUMBER_OF_PARAMETERS,
|
685 | ERR_UNSUPPORTED_DATA_TYPE,
|
686 | ERR_BIND_VALUE_AND_TYPE_MISMATCH,
|
687 | ERR_INVALID_BIND_DATA_TYPE,
|
688 | ERR_INVALID_BIND_DIRECTION,
|
689 | ERR_NO_TYPE_FOR_CONVERSION,
|
690 | ERR_INSUFFICIENT_BUFFER_FOR_BINDS,
|
691 | ERR_BUSY_RS,
|
692 | ERR_INVALID_RS,
|
693 | ERR_NOT_A_QUERY,
|
694 | ERR_INVALID_TYPE_FOR_CONVERSION,
|
695 | ERR_INVALID_LOB,
|
696 | ERR_BUSY_LOB,
|
697 | ERR_INSUFFICIENT_MEMORY,
|
698 | ERR_INVALID_TYPE_FOR_ARRAY_BIND,
|
699 | ERR_REQUIRED_MAX_ARRAY_SIZE,
|
700 | ERR_INVALID_ARRAY_SIZE,
|
701 | ERR_INCOMPATIBLE_TYPE_ARRAY_BIND,
|
702 | ERR_CONN_REQUEST_TIMEOUT,
|
703 | ERR_CANNOT_CONVERT_RS_TO_STREAM,
|
704 | ERR_CANNOT_INVOKE_RS_METHODS,
|
705 | ERR_RS_ALREADY_CONVERTED,
|
706 | ERR_INVALID_BIND_UNIT,
|
707 | ERR_CANNOT_LOAD_BINARY,
|
708 | ERR_POOL_WITH_ALIAS_ALREADY_EXISTS,
|
709 | ERR_POOL_WITH_ALIAS_NOT_FOUND,
|
710 | ERR_INCOMPATIBLE_TYPE_ARRAY_INDEX_BIND,
|
711 | ERR_MIXED_BIND,
|
712 | ERR_MISSING_MAX_SIZE_BY_POS,
|
713 | ERR_MISSING_MAX_SIZE_BY_NAME,
|
714 | ERR_MAX_SIZE_TOO_SMALL,
|
715 | ERR_MISSING_TYPE_BY_POS,
|
716 | ERR_MISSING_TYPE_BY_NAME,
|
717 | ERR_INVALID_SUBSCR,
|
718 | ERR_MISSING_SUBSCR_CALLBACK,
|
719 | ERR_MISSING_SUBSCR_SQL,
|
720 | ERR_POOL_CLOSING,
|
721 | ERR_POOL_CLOSED,
|
722 | ERR_INVALID_SODA_DOC_CURSOR,
|
723 | ERR_NO_BINARY_AVAILABLE,
|
724 | ERR_INVALID_ERR_NUM,
|
725 | ERR_NODE_TOO_OLD,
|
726 | ERR_INVALID_AQ_MESSAGE,
|
727 | ERR_DBL_CONNECT_STRING,
|
728 | ERR_QUEUE_MAX_EXCEEDED,
|
729 | ERR_UNSUPPORTED_DATA_TYPE_IN_JSON,
|
730 | ERR_DBL_USER,
|
731 | ERR_CONCURRENT_OPS,
|
732 | ERR_POOL_RECONFIGURING,
|
733 | ERR_POOL_STATISTICS_DISABLED,
|
734 | ERR_TOKEN_BASED_AUTH,
|
735 | ERR_POOL_TOKEN_BASED_AUTH,
|
736 | ERR_CONN_TOKEN_BASED_AUTH,
|
737 | ERR_TOKEN_HAS_EXPIRED,
|
738 | ERR_NOT_IMPLEMENTED,
|
739 | ERR_INIT_ORACLE_CLIENT_ARGS,
|
740 | ERR_MISSING_FILE,
|
741 | ERR_INVALID_NUMBER_OF_CONNECTIONS,
|
742 | ERR_EXEC_MODE_ONLY_FOR_DML,
|
743 | ERR_CONNECTION_CLOSED,
|
744 | ERR_CONNECTION_LOSTCONTACT,
|
745 | ERR_CONNECTION_INCOMPLETE,
|
746 | ERR_PROXY_CONNECTION_FAILURE,
|
747 | ERR_TLS_INIT_FAILURE,
|
748 | ERR_TLS_AUTH_FAILURE,
|
749 | ERR_TLS_DNMATCH_FAILURE,
|
750 | ERR_TLS_HOSTMATCH_FAILURE,
|
751 | ERR_INVALID_PACKET,
|
752 | ERR_CONNECTION_TIMEDOUT,
|
753 | ERR_CONNECTION_REFUSED,
|
754 | ERR_INVALID_CONNECT_STRING_PARAMETERS,
|
755 | ERR_CONNECTION_INBAND,
|
756 | ERR_INVALID_CONNECT_STRING_SYNTAX,
|
757 | ERR_INVALID_EZCONNECT_SYNTAX,
|
758 | ERR_NO_CONFIG_DIR,
|
759 | ERR_TNS_ENTRY_NOT_FOUND,
|
760 | ERR_CONNECTION_EOF,
|
761 | ERR_INVALID_BIND_NAME,
|
762 | ERR_WRONG_NUMBER_OF_POSITIONAL_BINDS,
|
763 | ERR_BUFFER_LENGTH_INSUFFICIENT,
|
764 | ERR_NCHAR_CS_NOT_SUPPORTED,
|
765 | ERR_MISSING_CREDENTIALS,
|
766 | ERR_UNEXPECTED_END_OF_DATA,
|
767 | ERR_UNEXPECTED_MESSAGE_TYPE,
|
768 | ERR_POOL_HAS_BUSY_CONNECTIONS,
|
769 | ERR_INTERNAL,
|
770 | ERR_INVALID_REF_CURSOR,
|
771 | ERR_UNSUPPORTED_VERIFIER_TYPE,
|
772 | ERR_NAN_VALUE,
|
773 | ERR_ORACLE_NUMBER_NO_REPR,
|
774 | ERR_INVALID_SERVICE_NAME,
|
775 | ERR_INVALID_SID,
|
776 | ERR_TNS_NAMES_FILE_MISSING,
|
777 | ERR_INVALID_TYPE_NUM,
|
778 | ERR_INVALID_ORACLE_TYPE_NUM,
|
779 | ERR_UNEXPECTED_NEGATIVE_INTEGER,
|
780 | ERR_INTEGER_TOO_LARGE,
|
781 | ERR_UNEXPECTED_DATA,
|
782 | ERR_OSON_FIELD_NAME_LIMITATION,
|
783 | ERR_OSON_VERSION_NOT_SUPPORTED,
|
784 | ERR_THIN_CONNECTION_ALREADY_CREATED,
|
785 | ERR_UNSUPPORTED_CONVERSION,
|
786 | ERR_FETCH_TYPE_HANDLER_RETURN_VALUE,
|
787 | ERR_FETCH_TYPE_HANDLER_TYPE,
|
788 | ERR_FETCH_TYPE_HANDLER_CONVERTER,
|
789 | ERR_CALL_TIMEOUT_EXCEEDED,
|
790 | ERR_EMPTY_CONNECT_STRING,
|
791 | ERR_UNKOWN_SERVER_SIDE_PIGGYBACK,
|
792 | ERR_UNKNOWN_COLUMN_TYPE_NAME,
|
793 | ERR_INVALID_OBJECT_TYPE_NAME,
|
794 | ERR_TDS_TYPE_NOT_SUPPORTED,
|
795 | ERR_INVALID_COLL_INDEX_SET,
|
796 | ERR_INVALID_COLL_INDEX_GET,
|
797 | ERR_DELETE_ELEMENTS_OF_VARRAY,
|
798 | ERR_WRONG_VALUE_FOR_DBOBJECT_ATTR,
|
799 | ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM,
|
800 | ERR_WRONG_CRED_FOR_EXTAUTH,
|
801 | ERR_MISSING_BIND_VALUE,
|
802 | ERR_SERVER_VERSION_NOT_SUPPORTED,
|
803 | ERR_UNEXPECTED_XML_TYPE,
|
804 | ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY,
|
805 | ERR_TOO_MANY_BATCH_ERRORS,
|
806 | ERR_WRONG_LENGTH_FOR_DBOBJECT_ATTR,
|
807 | ERR_WRONG_LENGTH_FOR_DBOBJECT_ELEM,
|
808 | ERR_VECTOR_FORMAT_NOT_SUPPORTED,
|
809 | ERR_VECTOR_VERSION_NOT_SUPPORTED,
|
810 | ERR_OBJECT_IS_NOT_A_COLLECTION,
|
811 | ERR_CONNECTION_CLOSED_CODE: `${ERR_PREFIX}-${ERR_CONNECTION_CLOSED}`,
|
812 | WRN_COMPILATION_CREATE,
|
813 | assert,
|
814 | assertArgCount,
|
815 | assertParamPropBool,
|
816 | assertParamPropFunction,
|
817 | assertParamPropInt,
|
818 | assertParamPropString,
|
819 | assertParamPropUnsignedInt,
|
820 | assertParamPropValue,
|
821 | assertParamValue,
|
822 | assertPropValue,
|
823 | getErr,
|
824 | throwErr,
|
825 | throwNotImplemented,
|
826 | transformErr
|
827 | };
|