-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Richard Bair <[email protected]>
- Loading branch information
Showing
16 changed files
with
535 additions
and
313 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
pbj-core/pbj-grpc-helidon/src/main/java/com/hedera/pbj/grpc/helidon/FatalGrpcException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.hedera.pbj.grpc.helidon; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import io.helidon.http.Header; | ||
import io.helidon.http.Status; | ||
import io.helidon.http.WritableHeaders; | ||
import io.helidon.http.http2.Http2Headers; | ||
import java.util.function.Consumer; | ||
|
||
class FatalGrpcException extends Exception { | ||
final Consumer<WritableHeaders<?>> headerCallback; | ||
|
||
FatalGrpcException(final @NonNull Consumer<WritableHeaders<?>> headerCallback) { | ||
this.headerCallback = headerCallback; | ||
} | ||
|
||
FatalGrpcException(final @NonNull Header grpcStatus) { | ||
this(w -> { | ||
w.set(Http2Headers.STATUS_NAME, Status.OK_200.code()); | ||
w.set(grpcStatus); | ||
}); | ||
} | ||
|
||
FatalGrpcException(final @NonNull Status status) { | ||
this(w -> w.set(Http2Headers.STATUS_NAME, status.code())); | ||
} | ||
|
||
FatalGrpcException(final @NonNull Status status, final @NonNull Header grpcStatus) { | ||
this(w -> { | ||
w.set(Http2Headers.STATUS_NAME, status.code()); | ||
w.set(grpcStatus); | ||
}); | ||
} | ||
|
||
final Consumer<WritableHeaders<?>> headerCallback() { | ||
return headerCallback; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.