Override getMessage in Exceptions instead of toString (#7002)

Fixes https://errorprone.info/bugpattern/OverrideThrowableToString
This commit is contained in:
David Vo
2024-08-27 10:32:32 +10:00
committed by GitHub
parent 1daff9193c
commit 0352a60f38
3 changed files with 4 additions and 9 deletions

View File

@@ -73,7 +73,7 @@ public class BadSchemaException extends Exception {
}
@Override
public String toString() {
return m_field.isEmpty() ? getMessage() : "field " + m_field + ": " + getMessage();
public String getMessage() {
return m_field.isEmpty() ? super.getMessage() : "field " + m_field + ": " + super.getMessage();
}
}

View File

@@ -53,7 +53,7 @@ public class ParseException extends Exception {
}
@Override
public String toString() {
return m_pos + ": " + getMessage();
public String getMessage() {
return m_pos + ": " + super.getMessage();
}
}