Skip to content

Commit 65ee65d

Browse files
committed
Improved error messages as requested by Walmart
1 parent 87a67ab commit 65ee65d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMSAL4JUtils.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static SqlAuthenticationToken getSqlFedAuthToken(SqlFedAuthInfo fedAuthInfo, Str
145145
} catch (MalformedURLException | ExecutionException e) {
146146
throw getCorrectedException(e, user, authenticationString);
147147
} catch (TimeoutException e) {
148-
throw new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e);
148+
throw getCorrectedException(new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e), user, authenticationString);
149149
} finally {
150150
if (isSemAcquired) {
151151
sem.release();
@@ -223,7 +223,7 @@ static SqlAuthenticationToken getSqlFedAuthTokenPrincipal(SqlFedAuthInfo fedAuth
223223
} catch (MalformedURLException | ExecutionException e) {
224224
throw getCorrectedException(e, aadPrincipalID, authenticationString);
225225
} catch (TimeoutException e) {
226-
throw new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e);
226+
throw getCorrectedException(new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e), aadPrincipalID, authenticationString);
227227
} finally {
228228
if (isSemAcquired) {
229229
sem.release();
@@ -354,7 +354,7 @@ static SqlAuthenticationToken getSqlFedAuthTokenPrincipalCertificate(SqlFedAuthI
354354
throw new SQLServerException(SQLServerException.getErrString("R_readCertError") + e.getMessage(), null, 0,
355355
null);
356356
} catch (TimeoutException e) {
357-
throw new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e);
357+
throw getCorrectedException(new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e), aadPrincipalID, authenticationString);
358358
} catch (Exception e) {
359359
throw getCorrectedException(e, aadPrincipalID, authenticationString);
360360

@@ -420,7 +420,7 @@ static SqlAuthenticationToken getSqlFedAuthTokenIntegrated(SqlFedAuthInfo fedAut
420420
} catch (IOException | ExecutionException e) {
421421
throw getCorrectedException(e, user, authenticationString);
422422
} catch (TimeoutException e) {
423-
throw new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e);
423+
throw getCorrectedException(new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e), user, authenticationString);
424424
} finally {
425425
if (isSemAcquired) {
426426
sem.release();
@@ -526,7 +526,7 @@ static SqlAuthenticationToken getSqlFedAuthTokenInteractive(SqlFedAuthInfo fedAu
526526
} catch (MalformedURLException | URISyntaxException | ExecutionException e) {
527527
throw getCorrectedException(e, user, authenticationString);
528528
} catch (TimeoutException e) {
529-
throw new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e);
529+
throw getCorrectedException(new SQLServerException(SQLServerException.getErrString("R_connectionTimedOut"), e), user, authenticationString);
530530
} finally {
531531
if (isSemAcquired) {
532532
sem.release();

src/test/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ public void testGetSqlFedAuthTokenFailure() throws SQLException {
13361336
fail(TestResource.getResource("R_expectedExceptionNotThrown"));
13371337
} catch (SQLServerException e) {
13381338
//test pass
1339-
assertEquals(e.getMessage(), SQLServerException.getErrString("R_connectionTimedOut"), "Expected Timeout Exception was not thrown");
1339+
assertTrue(e.getMessage().contains(SQLServerException.getErrString("R_connectionTimedOut")), "Expected Timeout Exception was not thrown");
13401340
}
13411341
}
13421342

@@ -1351,7 +1351,7 @@ public void testGetSqlFedAuthTokenFailureNoWaiting() throws SQLException {
13511351
fail(TestResource.getResource("R_expectedExceptionNotThrown"));
13521352
} catch (SQLServerException e) {
13531353
//test pass
1354-
assertEquals(e.getMessage(), SQLServerException.getErrString("R_connectionTimedOut"), "Expected Timeout Exception was not thrown");
1354+
assertTrue(e.getMessage().contains(SQLServerException.getErrString("R_connectionTimedOut")), "Expected Timeout Exception was not thrown");
13551355
}
13561356
}
13571357

@@ -1366,7 +1366,7 @@ public void testGetSqlFedAuthTokenFailureNagativeWaiting() throws SQLException {
13661366
fail(TestResource.getResource("R_expectedExceptionNotThrown"));
13671367
} catch (SQLServerException e) {
13681368
//test pass
1369-
assertEquals(e.getMessage(), SQLServerException.getErrString("R_connectionTimedOut"), "Expected Timeout Exception was not thrown");
1369+
assertTrue(e.getMessage().contains(SQLServerException.getErrString("R_connectionTimedOut")), "Expected Timeout Exception was not thrown");
13701370
}
13711371
}
13721372

0 commit comments

Comments
 (0)