From 978cbb84c4b93a871a9c5499a74b54fac6c96c65 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Tue, 19 Sep 2023 16:24:48 +0200 Subject: [PATCH] [errorprone] Exceptions should not override #toString Instead of overriding #toString provide getter for additional information so that code handling the exception can access it. See https://errorprone.info/bugpattern/OverrideThrowableToString Change-Id: Ie577ae9327e0234d55481253f2604b1644ea3f01 --- .../eclipse/jgit/errors/PackMismatchException.java | 5 ----- .../eclipse/jgit/errors/RevisionSyntaxException.java | 11 ++++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java index 7a2c70de7..e630f529e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java @@ -51,9 +51,4 @@ public void setPermanent(boolean permanent) { public boolean isPermanent() { return permanent; } - - @Override - public String toString() { - return super.toString() + ", permanent: " + permanent; //$NON-NLS-1$ - } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java index 83876ef03..293b4c681 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java @@ -44,8 +44,13 @@ public RevisionSyntaxException(String message, String revstr) { this.revstr = revstr; } - @Override - public String toString() { - return super.toString() + ":" + revstr; //$NON-NLS-1$ + /** + * Get the problematic revision string + * + * @return the problematic revision string + * @since 6.8 + */ + public String getRevstr() { + return revstr; } }