Skip to content

Commit

Permalink
Refactor: Simplify if/switch with if statement on comment error utils
Browse files Browse the repository at this point in the history
Related PR Comment: https://github.com/wordpress-mobile/
WordPress-FluxC-Android/pull/2870#discussion_r1363993819
  • Loading branch information
ParaskP7 committed Oct 19, 2023
1 parent 94fbe92 commit 1b43bf0
Showing 1 changed file with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,8 @@ public static CommentError networkToCommentError(@NonNull BaseNetworkError error
@NonNull
private static CommentErrorType genericToCommentError(@NonNull BaseNetworkError error) {
CommentErrorType errorType = CommentErrorType.GENERIC_ERROR;
if (error.isGeneric()) {
switch (error.type) {
case INVALID_RESPONSE:
errorType = CommentErrorType.INVALID_RESPONSE;
break;
case TIMEOUT:
case NO_CONNECTION:
case NETWORK_ERROR:
case NOT_FOUND:
case CENSORED:
case SERVER_ERROR:
case INVALID_SSL_CERTIFICATE:
case HTTP_AUTH_ERROR:
case AUTHORIZATION_REQUIRED:
case NOT_AUTHENTICATED:
case PARSE_ERROR:
case UNKNOWN:
break;
}
if (error.isGeneric() && error.type == GenericErrorType.INVALID_RESPONSE) {
errorType = CommentErrorType.INVALID_RESPONSE;
}
if (error instanceof WPComGsonNetworkError) {
WPComGsonNetworkError wpComGsonNetworkError = (WPComGsonNetworkError) error;
Expand Down

0 comments on commit 1b43bf0

Please sign in to comment.