Skip to content

Commit

Permalink
noop(preventing bugs) keep assertion after switch (#1407)
Browse files Browse the repository at this point in the history
internal linter pointed out the assertion being on the `default` case
prevents javac from telling us when a switch is insufficient.
  • Loading branch information
jzacsh authored Dec 9, 2024
1 parent 88c75ef commit fb5bc74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* <p>Example usage error handling workflow:
*
* <pre>
* <pre>{@code
* MicrosoftApiResponse resp = someServerCall();
* Optional<RecoverableState> recovery = resp.recoverableState();
* if (recovery.isPresent()) {
Expand All @@ -48,7 +48,7 @@
* }
* }
* resp.throwDtpException(); // or returnConvertDtpException might help
* </pre>
* }</pre>
*/
@AutoValue
public abstract class MicrosoftApiResponse {
Expand Down Expand Up @@ -163,9 +163,8 @@ public void throwDtpException(String message)
"Microsoft destination storage limit reached", toIoException(message));
case FATAL_STATE_FATAL_UNSPECIFIED:
throw toIoException(String.format("%s: %s", CAUSE_PREFIX_UNRECOGNIZED_EXCEPTION, message));
default:
throw new AssertionError("exhaustive switch");
}
throw new AssertionError("exhaustive switch");
}

/**
Expand Down Expand Up @@ -208,6 +207,8 @@ public IOException toIoException() {
}

/**
* Produce {@link toIoException} with a message used to construct the exception's cause.
*
* @param message The cause-message one might expect with a {@link java.lang.Exception}
* construction.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ private void logDebugJobStatus(String format, UUID jobId, MediaContainerResource
}

/** Returns a folder ID after asking Microsoft APIs to allocate one for the given album. */
@SuppressWarnings("unchecked")
private String createOneDriveFolder(MediaAlbum album)
throws IOException, CopyExceptionWithFailureReason {
Map<String, Object> rawFolder = new LinkedHashMap<>();
Expand Down Expand Up @@ -377,11 +376,11 @@ private Pair<Request, MicrosoftApiResponse> tryWithCreds(Request.Builder request
*
* <p>Example usage:
*
* <pre>
* <pre>{@code
* MicrosoftApiResponse resp = tryWithCredsOrFail(request, "creating a folder");
* checkState(resp.isOkay(), "bug: tryWithCredsOrFail() should have returne healthy resp");
* // ...carry on as normal with business logic...
* </pre>
* }</pre>
*
* @param causeMessage a contextual message to include as the root cause/context when throwing a
* DTP excption.
Expand All @@ -401,9 +400,8 @@ private MicrosoftApiResponse tryWithCredsOrFail(Request.Builder req, String caus
String.format(
"bug! microsoft server needs token refresh immediately after a refreshing: %s",
causeMessage));
default:
throw new AssertionError("exhaustive switch");
}
throw new AssertionError("exhaustive switch");
}
return response.returnConvertDtpException(
String.format(
Expand All @@ -417,10 +415,10 @@ private MicrosoftApiResponse tryWithCredsOrFail(Request.Builder req, String caus
*
* <p>Example usage:
*
* <pre>
* <pre>{@code
* @Nonnull String folderId = tryWithCredsOrFail(request, "folderId", "creating a folder");
* // ...carry on as normal with business logic...
* </pre>
* }</pre>
*
* @param jsonResponseKey the top-level value to extract from the response body.
* @param causeMessage a contextual message to include as the root cause/context when throwing a
Expand Down

0 comments on commit fb5bc74

Please sign in to comment.