Make RestApiException(String, Exception) constructor protected
This constructor should only be used by subclasses and for wrapping other exceptions, but not for signaling internal server errors. Throwing RestApiExceptions to signal internal server errors is bad since all RestApiExceptions are exempt from retries and auto-tracing. To prevent that a RestApiException is accidentally thrown to signal an internal server error we: * make the RestApiException(String, Exception) constructor protected so that it can only be used by subclasses * offer a static method for exception wrapping Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I3495cb63f66a669ac5849d5f28c3ce8cc4e5ae95
This commit is contained in:
@@ -32,7 +32,7 @@ public class ApiUtil {
|
||||
public static RestApiException asRestApiException(String msg, Exception e)
|
||||
throws RuntimeException {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
return e instanceof RestApiException ? (RestApiException) e : new RestApiException(msg, e);
|
||||
return e instanceof RestApiException ? (RestApiException) e : RestApiException.wrap(msg, e);
|
||||
}
|
||||
|
||||
private ApiUtil() {}
|
||||
|
||||
Reference in New Issue
Block a user