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

Correctly translate quiche error to QuicException that have no transp… #736

Merged
merged 1 commit into from
Jul 19, 2024
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 @@ -15,13 +15,20 @@
*/
package io.netty.incubator.codec.quic;

import org.jetbrains.annotations.Nullable;

/**
* Exception produced while processing {@code QUIC}.
*/
public final class QuicException extends Exception {

private final QuicTransportError error;

QuicException(String message) {
super(message);
this.error = null;
}

public QuicException(QuicTransportError error) {
super(error.name());
this.error = error;
Expand All @@ -42,12 +49,13 @@ public QuicException(String message, Throwable cause, QuicTransportError error)
this.error = error;
}


/**
* Returns the {@link QuicTransportError} which was the cause of the {@link QuicException}.
*
* @return the {@link QuicTransportError} that caused this {@link QuicException}.
* @return the {@link QuicTransportError} that caused this {@link QuicException} or {@code null} if
* it was caused by something different.
*/
@Nullable
public QuicTransportError error() {
return error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,10 @@ static long getPrimitiveValue(ByteBuffer memory, int offset, int valueType) {

static Exception convertToException(int result) {
QuicTransportErrorHolder holder = ERROR_MAPPINGS.get(result);
assert holder != null;
if (holder == null) {
// There is no mapping to a transport error, it's something internal so throw it directly.
return new QuicException(QuicheError.valueOf(result).message());
}
Exception exception = new QuicException(holder.error + ": " + holder.quicheErrorName, holder.error);
if (result == QUICHE_ERR_TLS_FAIL) {
String lastSslError = BoringSSL.ERR_last_error();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,4 @@ static QuicheError valueOf(int code) {
}
return errorCode;
}


}
Loading