Skip to content

Commit

Permalink
#2868: super minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
uweschaefer committed Jun 3, 2024
1 parent 5e7744a commit 353c676
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@
public class ServerExceptionHelper {

public static StatusRuntimeException translate(Throwable e, Metadata meta) {
if (e instanceof StatusRuntimeException) // prevent double wrap
if (e instanceof StatusRuntimeException sre) // prevent double wrap
{
return (StatusRuntimeException) e;
return sre;
} else if (e instanceof RuntimeException
&& e.getClass().getName().startsWith("org.factcast.core")) {

return new StatusRuntimeException(Status.UNKNOWN, addMetaData(meta, e));
} else if (e instanceof UnsupportedOperationException) {
// UNIMPLEMENTED is technically not fully correct but best we can do here
return new StatusRuntimeException(Status.UNIMPLEMENTED, meta);
} else if (e instanceof AuthenticationException) {
if (e instanceof AuthenticationCredentialsNotFoundException) {
return new StatusRuntimeException(Status.UNAUTHENTICATED, meta);
}
return new StatusRuntimeException(Status.PERMISSION_DENIED, meta);
} else return new StatusRuntimeException(Status.PERMISSION_DENIED, meta);
} else {
return new StatusRuntimeException(Status.UNKNOWN, meta);
}
Expand Down

0 comments on commit 353c676

Please sign in to comment.