2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2020-06-30 12:48:07 +02:00
|
|
|
include::description.adoc[]
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Noncompliant code example
|
|
|
|
|
|
|
|
[source,text]
|
|
|
|
----
|
|
|
|
public class FruitException { // Noncompliant; this has nothing to do with Exception
|
|
|
|
private Fruit expected;
|
|
|
|
private String unusualCharacteristics;
|
|
|
|
private boolean appropriateForCommercialExploitation;
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CarException { // Noncompliant; the extends clause was forgotten?
|
|
|
|
public CarException(String message, Throwable cause) {
|
|
|
|
// ...
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
|
|
|
|
[source,text]
|
|
|
|
----
|
|
|
|
public class FruitSport {
|
|
|
|
private Fruit expected;
|
|
|
|
private String unusualCharacteristics;
|
|
|
|
private boolean appropriateForCommercialExploitation;
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CarException extends Exception {
|
|
|
|
public CarException(String message, Throwable cause) {
|
|
|
|
// ...
|
|
|
|
----
|
2020-06-30 12:48:07 +02:00
|
|
|
|