20
20
import net .snowflake .client .core .ObjectMapperFactory ;
21
21
import net .snowflake .client .core .SFBaseSession ;
22
22
import net .snowflake .client .core .SFException ;
23
+ import net .snowflake .client .core .SFSession ;
23
24
import net .snowflake .client .jdbc .telemetry .Telemetry ;
24
25
import net .snowflake .client .jdbc .telemetry .TelemetryField ;
25
26
import net .snowflake .client .jdbc .telemetry .TelemetryUtil ;
@@ -41,6 +42,13 @@ public class SnowflakeSQLLoggedException extends SnowflakeSQLException {
41
42
private static final SFLogger logger =
42
43
SFLoggerFactory .getLogger (SnowflakeSQLLoggedException .class );
43
44
private static final ObjectMapper mapper = ObjectMapperFactory .getObjectMapper ();
45
+ private static final int NO_VENDOR_CODE = -1 ;
46
+
47
+ public SnowflakeSQLLoggedException (
48
+ String queryID , SFSession session , String sqlState , String message , Exception cause ) {
49
+ super (queryID , cause , sqlState , NO_VENDOR_CODE , message );
50
+ sendTelemetryData (queryID , sqlState , NO_VENDOR_CODE , session , this );
51
+ }
44
52
45
53
/**
46
54
* Function to create a TelemetryEvent log from the JSONObject and exception and send it via OOB
@@ -134,7 +142,7 @@ static JSONObject createOOBValue(String queryId, String SQLState, int vendorCode
134
142
if (!Strings .isNullOrEmpty (SQLState )) {
135
143
oobValue .put ("SQLState" , SQLState );
136
144
}
137
- if (vendorCode != - 1 ) {
145
+ if (vendorCode != NO_VENDOR_CODE ) {
138
146
oobValue .put ("ErrorNumber" , vendorCode );
139
147
}
140
148
return oobValue ;
@@ -159,7 +167,7 @@ static ObjectNode createIBValue(String queryId, String SQLState, int vendorCode)
159
167
if (!Strings .isNullOrEmpty (SQLState )) {
160
168
ibValue .put ("SQLState" , SQLState );
161
169
}
162
- if (vendorCode != - 1 ) {
170
+ if (vendorCode != NO_VENDOR_CODE ) {
163
171
ibValue .put ("ErrorNumber" , vendorCode );
164
172
}
165
173
return ibValue ;
@@ -281,7 +289,7 @@ public SnowflakeSQLLoggedException(SFBaseSession session, String SQLState, Strin
281
289
public SnowflakeSQLLoggedException (
282
290
String queryId , SFBaseSession session , String SQLState , String reason ) {
283
291
super (reason , SQLState );
284
- sendTelemetryData (queryId , SQLState , - 1 , session , this );
292
+ sendTelemetryData (queryId , SQLState , NO_VENDOR_CODE , session , this );
285
293
}
286
294
287
295
/**
@@ -374,7 +382,7 @@ public SnowflakeSQLLoggedException(SFBaseSession session, ErrorCode errorCode, O
374
382
public SnowflakeSQLLoggedException (
375
383
String queryId , SFBaseSession session , ErrorCode errorCode , Object ... params ) {
376
384
super (queryId , errorCode , params );
377
- sendTelemetryData (queryId , null , - 1 , session , this );
385
+ sendTelemetryData (queryId , null , NO_VENDOR_CODE , session , this );
378
386
}
379
387
380
388
/**
@@ -383,7 +391,7 @@ public SnowflakeSQLLoggedException(
383
391
*/
384
392
public SnowflakeSQLLoggedException (SFBaseSession session , SFException e ) {
385
393
super (e );
386
- sendTelemetryData (null , null , - 1 , session , this );
394
+ sendTelemetryData (null , null , NO_VENDOR_CODE , session , this );
387
395
}
388
396
389
397
/**
@@ -405,6 +413,6 @@ public SnowflakeSQLLoggedException(SFBaseSession session, String reason) {
405
413
*/
406
414
public SnowflakeSQLLoggedException (String queryId , SFBaseSession session , String reason ) {
407
415
super (queryId , reason , null );
408
- sendTelemetryData (queryId , null , - 1 , session , this );
416
+ sendTelemetryData (queryId , null , NO_VENDOR_CODE , session , this );
409
417
}
410
418
}
0 commit comments