Skip to content

fixing error message in a log statement#13791

Open
TZubiri wants to merge 1 commit intowso2:masterfrom
TZubiri:patch-1
Open

fixing error message in a log statement#13791
TZubiri wants to merge 1 commit intowso2:masterfrom
TZubiri:patch-1

Conversation

@TZubiri
Copy link
Copy Markdown

@TZubiri TZubiri commented Aug 9, 2025

It seems that the old message had been incorrectly copy pasted without modifying the error message.

Another issue might be that the potentially specific Exception is cast to the base Exception type, losing the more specific error signal.

What's interesting to note is that the try catch statement adds no value, removing it altogether would have actually fixed both issues.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fix incorrect exception message in ResourceAdminServiceClient.getMimeTypeFromHuman by updating the thrown message text.

  • Update exception message string to better reflect the operation.
  • No functional changes beyond message update.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 221 to 227
try {
return resourceAdminServiceStub.getMimeTypeFromHuman(mediaType);
} catch (Exception e) {
String msg = "get human readable media type error ";
String msg = "get mime type from human error ";
throw new Exception(msg, e);

}
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching Exception and rethrowing a new generic Exception obscures the original, more specific exception type and adds little value. Prefer either: (a) remove the try/catch and let the stub's exception propagate, or (b) rethrow the original exception (throw e;) to preserve type, or (c) wrap in a more specific checked exception used by this client rather than java.lang.Exception.

Copilot uses AI. Check for mistakes.
return resourceAdminServiceStub.getMimeTypeFromHuman(mediaType);
} catch (Exception e) {
String msg = "get human readable media type error ";
String msg = "get mime type from human error ";
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message is still unclear/grammatically awkward and ends with a trailing space. Consider a clearer, actionable message and include context, e.g., String msg = "Error getting MIME type from human-readable media type for: " + mediaType; (remove trailing space and improve capitalization).

Suggested change
String msg = "get mime type from human error ";
String msg = "Error getting MIME type from human-readable media type for: " + mediaType;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't quite matter or is highly secondary.

In situations where only the error message is logged, and not the exception stack, the error message serves more as an error ID than a useful descriptor, the logging debugging workflow will be grepping the exact error message through the codebases to find the exact codepath.

Logging the actual exception stack as-is might be a reasonable suggestion (with the counterargument that it might pollute log files), but is somewhat beyond the scope of this bug, which is that the bug id/msg is a duplicate, and thus code execution information is lost on logs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally the + mediaType introduces the possibility of type errors, which would risk an exception during exception error, making this suggestion hugely net negative.

We should think of code in a catch block as a second serve in tennis, slow and careful instead of featureful and optimistic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants