Skip to content

Commit

Permalink
Made InvalidConnectionString extend DataClientException so users can …
Browse files Browse the repository at this point in the history
…optionally catch the more specific exception
  • Loading branch information
cole committed Sep 28, 2024
1 parent 9049859 commit dc973a9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,10 @@ public Mono<String> processRequestAsync(KustoRequestContext request) {
}

private void validateEndpoint() throws DataServiceException, DataClientException {
try {
if (!endpointValidated) {
KustoTrustedEndpoints.validateTrustedEndpoint(clusterUrl,
CloudInfo.retrieveCloudInfoForCluster(clusterUrl).getLoginEndpoint());
endpointValidated = true;
}
} catch (KustoClientInvalidConnectionStringException e) {
throw new DataClientException(clusterUrl, e.getMessage(), e);
if (!endpointValidated) {
KustoTrustedEndpoints.validateTrustedEndpoint(clusterUrl,
CloudInfo.retrieveCloudInfoForCluster(clusterUrl).getLoginEndpoint());
endpointValidated = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void validateTrustedEndpoint(String uri, String loginEndpoint) thr
try {
validateTrustedEndpoint(new URI(uri), loginEndpoint);
} catch (URISyntaxException ex) {
throw new KustoClientInvalidConnectionStringException(ex);
throw new KustoClientInvalidConnectionStringException(uri, ex.getMessage(), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
This class represents an error that happened on the client side and is therefore considered permanent
*/
public class DataClientException extends KustoDataExceptionBase {
public DataClientException(Exception ex) {
this(ex.getMessage());
}

public DataClientException(String message) {
this(null, message);
}

public DataClientException(String ingestionSource, String message) {
this(ingestionSource, message, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
/**
* Raised when Kusto client is initialized with an invalid endpoint
*/
public class KustoClientInvalidConnectionStringException extends Exception {
public class KustoClientInvalidConnectionStringException extends DataClientException {
public KustoClientInvalidConnectionStringException(Exception e) {
super(e);
}

public KustoClientInvalidConnectionStringException(String msg) {
super(msg);
}

public KustoClientInvalidConnectionStringException(String clusterURL, String msg, Exception e) {
super(clusterURL, msg, e);
}
}

0 comments on commit dc973a9

Please sign in to comment.