Java style guide: Avoid extraneous strings in Exceptions.

Change-Id: I34b87a55631eda7a76c5291c95444848c051b6cf
Reviewed-on: https://chromium-review.googlesource.com/1175861
Reviewed-by: Tommy Nyquist <[email protected]>
Reviewed-by: Ted Choc <[email protected]>
Commit-Queue: agrieve <[email protected]>
Cr-Commit-Position: refs/heads/master@{#583309}
diff --git a/styleguide/java/java.md b/styleguide/java/java.md
index 7b8b2ef7..62647ecbc 100644
--- a/styleguide/java/java.md
+++ b/styleguide/java/java.md
@@ -58,6 +58,22 @@
 }
 ```
 
+* Avoid adding messages to exceptions that do not aid in debugging.
+
+For example:
+```java
+try {
+  somethingThatThrowsIOException();
+} catch (IOException e) {
+  // Bad - message does not tell you more than the stack trace does:
+  throw new RuntimeException("Failed to parse a file.", e);
+  // Good - conveys that this block failed along with the "caused by" exception.
+  throw new RuntimeException(e);
+  // Good - adds useful information.
+  throw new RuntimeException(String.format("Failed to parse %s", fileName), e);
+}
+```
+
 ### Logging
 * Use `org.chromium.base.Log` instead of `android.util.Log`.
   * It provides `%s` support, and ensures log stripping works correctly.