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

More Error Info #683

Merged
merged 6 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* JNI bindings to the AWS Common Runtime
*/
public class HttpException extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My real dream for aws-crt-java would be to code-gen actual exception classes (not just enums) so Java programmers could do the idiomatic thing and:

catch (TlsNegotiationFailure e) {
    ...special...
}
catch (Exception e) {
    ...everything else...
}

instead of:

catch (HttpException e) {
    switch(e.getErrorInfo()) {
        case CrtErrorInfo.TLSNegotiationFailure:
            ...special...
            break;
        default:
            ...everything else (block 1)...
            break;
    }
}
catch (Exception e) {
    ...everything else (block 2)...
}

But that would technically be a breaking change, since we'd be changing the exact exception classes that get raised 😓

Would it be worth breaking those eggs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferring this convo to a later time. For now I can get by with the errir code being made public on the exception class

private int errorCode;
private final int errorCode;

/**
* Constructs a new HttpException
Expand All @@ -24,11 +24,11 @@ public HttpException(int errorCode) {
}

/**
* Returns the error code captured when the exception occurred. This can be fed to {@link CRT.awsErrorString} to
* Returns the error code captured when the exception occurred. This can be fed to CRT.awsErrorString() to
* get a user-friendly error string
* @return The error code associated with this exception
*/
int getErrorCode() {
public int getErrorCode() {
return errorCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ public void benchmarkS3Get() {
// resolution
final int vipsNeeded = (int) Math.ceil(expectedGbps / 0.5 / 10);
final int sampleDelay = Integer.parseInt(System.getProperty("aws.crt.s3.benchmark.warmup",
new Integer((int) Math.ceil(vipsNeeded / 5)).toString()));
Integer.toString((int) Math.ceil(vipsNeeded / 5))));
System.out.println(String.format("REGION=%s, WARMUP=%s", region, sampleDelay));

// Ignore stats during warm up time, they skew results
Expand Down Expand Up @@ -1402,7 +1402,7 @@ public void benchmarkS3Put() {
// resolution
final int vipsNeeded = (int) Math.ceil(expectedGbps / 0.5 / 10);
final int sampleDelay = Integer.parseInt(System.getProperty("aws.crt.s3.benchmark.warmup",
new Integer((int) Math.ceil(vipsNeeded / 5)).toString()));
Integer.toString((int) Math.ceil(vipsNeeded / 5))));
System.out.println(String.format("REGION=%s, WARMUP=%s", region, sampleDelay));

// Ignore stats during warm up time, they skew results
Expand Down
Loading