Skip to content

Commit

Permalink
Fixed error message formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mmahmud committed Aug 5, 2019
1 parent 86bc106 commit 0d55802
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 32 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
list or checking for Java class equivalency.


#### Changed
- Error message format when endpoint submission fails altogether (whether
no connection can be made or if the database returns some error).


### Version 7.0.5.0 - 2019-07-21

#### Added
Expand Down
76 changes: 44 additions & 32 deletions api/src/main/java/com/gpudb/GPUdbBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1077,9 +1077,10 @@ private URL switchURL(URL oldURL) throws GPUdbHAUnavailableException {
synchronized (urlLock) {
// If there is only one URL, then we can't switch URLs
if ( this.urls.size() == 1 ) {
throw new GPUdbHAUnavailableException("GPUdb unavailable at "
throw new GPUdbHAUnavailableException(" (GPUdb server at "
+ this.urls.get(0).toString()
+ " (no HA available to fall back on).");
+ " returned error; no HA clusters "
+ "available to fall back on).");
}

// Increment the index by one (mod url list length)
Expand All @@ -1096,8 +1097,9 @@ private URL switchURL(URL oldURL) throws GPUdbHAUnavailableException {
randomizeURLs();

// Let the user know that we've circled back
throw new GPUdbHAUnavailableException("GPUdb unavailable; have tried all HA clusters "
+ "head nodes (" + this.urls.toString() + ")");
throw new GPUdbHAUnavailableException(" (all GPUdb clusters with "
+ "head nodes [" + this.urls.toString()
+ "] returned error)");
}

// Haven't circled back to the old URL; so return the new one
Expand All @@ -1115,9 +1117,10 @@ private URL switchHmURL(URL oldURL) throws GPUdbHAUnavailableException {
synchronized (urlLock) {
// If there is only one URL, then we can't switch URLs
if ( this.hmUrls.size() == 1 ) {
throw new GPUdbHAUnavailableException("GPUdb unavailable at "
throw new GPUdbHAUnavailableException(" (host manager at "
+ this.hmUrls.get(0).toString()
+ " (no HA available to fall back on).");
+ "returned error; no HA clusters "
+ "available to fall back on).");
}

// Increment the index by one (mod url list length)
Expand All @@ -1134,8 +1137,9 @@ private URL switchHmURL(URL oldURL) throws GPUdbHAUnavailableException {
randomizeURLs();

// Let the user know that we've circled back
throw new GPUdbHAUnavailableException("GPUdb unavailable; have tried all HA clusters "
+ "head nodes (" + this.hmUrls.toString() + ")");
throw new GPUdbHAUnavailableException(" (all host managers at GPUdb clusters with "
+ "head nodes [" + this.hmUrls.toString()
+ "] returned error)");
}

// Haven't circled back to the old URL; so return the new one
Expand Down Expand Up @@ -1712,20 +1716,22 @@ public <T extends IndexedRecord> T submitRequest( String endpoint,
url = switchURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
throw new GPUdbException( ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause(), true );
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new GPUdbException( originalCause
+ ha_ex.getMessage(), true );
}
} catch (SubmitException ex) {
// Some error occurred during the HTTP request
try {
url = switchURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new SubmitException( null, ex.getRequest(), ex.getRequestSize(),
(ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause()),
(originalCause
+ ha_ex.getMessage()),
ex.getCause(), true );
}
} catch (GPUdbException ex) {
Expand All @@ -1737,9 +1743,10 @@ public <T extends IndexedRecord> T submitRequest( String endpoint,
url = switchURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
throw new GPUdbException( ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause(), true );
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new GPUdbException( originalCause
+ ha_ex.getMessage(), true );
}
}
} // end while
Expand Down Expand Up @@ -1808,9 +1815,10 @@ public <T extends IndexedRecord> T submitRequestToHM( String endpoint,
hmUrl = switchHmURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
throw new GPUdbException( ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause(), true );
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new GPUdbException( originalCause
+ ha_ex.getMessage(), true );
}
} catch (SubmitException ex) {
// Some error occurred during the HTTP request;
Expand All @@ -1825,10 +1833,11 @@ public <T extends IndexedRecord> T submitRequestToHM( String endpoint,
hmUrl = switchHmURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new SubmitException( null, ex.getRequest(), ex.getRequestSize(),
(ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause()),
(originalCause
+ ha_ex.getMessage()),
ex.getCause(), true );
}
}
Expand All @@ -1838,10 +1847,11 @@ public <T extends IndexedRecord> T submitRequestToHM( String endpoint,
hmUrl = switchHmURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new SubmitException( null, ex.getRequest(), ex.getRequestSize(),
(ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause()),
(originalCause
+ ha_ex.getMessage()),
ex.getCause(), true );
}
}
Expand All @@ -1852,9 +1862,10 @@ public <T extends IndexedRecord> T submitRequestToHM( String endpoint,
hmUrl = switchHmURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
throw new GPUdbException( ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause(), true );
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new GPUdbException( originalCause
+ ha_ex.getMessage(), true );
}
}
else {
Expand All @@ -1867,9 +1878,10 @@ public <T extends IndexedRecord> T submitRequestToHM( String endpoint,
hmUrl = switchHmURL( originalURL );
} catch (GPUdbHAUnavailableException ha_ex) {
// We've now tried all the HA clusters and circled back
throw new GPUdbException( ha_ex.getMessage()
+ "; original exception: "
+ ex.getCause(), true );
// Get the original cause to propagate to the user
String originalCause = (ex.getCause() == null) ? ex.toString() : ex.getCause().toString();
throw new GPUdbException( originalCause
+ ha_ex.getMessage(), true );
}
}
} // end while
Expand Down

0 comments on commit 0d55802

Please sign in to comment.