
org.lognet.springboot.grpc.recovery.ErrorHandlerAdapter Maven / Gradle / Ivy
// Generated by delombok at Mon Jul 31 05:34:41 UTC 2023
package org.lognet.springboot.grpc.recovery;
import io.grpc.Status;
import java.util.Optional;
import org.lognet.springboot.grpc.GRpcErrorHandler;
public class ErrorHandlerAdapter {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.Logger log =
org.slf4j.LoggerFactory.getLogger(ErrorHandlerAdapter.class);
private final Optional errorHandler;
public ErrorHandlerAdapter(Optional errorHandler) {
this.errorHandler = errorHandler;
}
protected Status handle(Exception e, Status status, GRpcExceptionScope scope) {
if (errorHandler.isPresent()) {
return errorHandler
.get()
.handle(
scope.getRequestOrResponse(),
status,
e,
scope.getCallHeaders(),
scope.getResponseHeaders());
} else {
log.error("Got error with status {} ", status.getCode().name(), e);
return status.withDescription(e.getMessage());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy