Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose errorCode/awsErrorName in HttpException #167

Closed
adamthom-amzn opened this issue Mar 13, 2020 · 1 comment
Closed

Expose errorCode/awsErrorName in HttpException #167

adamthom-amzn opened this issue Mar 13, 2020 · 1 comment
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue

Comments

@adamthom-amzn
Copy link

getErrorCode() in software.amazon.awssdk.crt.http.HttpException is package-private, which means the only method available to classify errors is to parse the message. When we fail to acquire a connection, we throw different exceptions to our consumers (HttpFailureException for generic connection failures, and HttpConnectionTimeoutException if it was specifically a timeout), which leads to brittle and obviously incorrect classification such as the below:

if (err.getMessage() != null && err.getMessage().contains("negotiation failed")) {
    throw new HttpFailureException(err.getMessage());
}

final String msg = format("Failed to get connection within %d ms: %s",
        params.getConnectionTimeoutMillis(), err.getMessage());
    throw new HttpConnectionTimeoutException(msg);
}

In general, I support a singular exception type as it makes error handling cleaner in cases when we don't particularly care about the cause of the exception. Exposing the errorCode or the result of CRT.awsErrorName(errorCode) would be sufficient for cases where we do care.

@bretambrose bretambrose added the feature-request A feature should be added or improved. label Sep 18, 2020
@yasminetalby yasminetalby added the p3 This is a minor priority issue label Jun 26, 2023
@jmklix
Copy link
Member

jmklix commented May 6, 2024

We add more error information here: #683
please let us know if there is anything else that is needed

@jmklix jmklix closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

4 participants