Skip to content

Commit 0755709

Browse files
Update metadata and description
1 parent 29ca18a commit 0755709

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

rules/S8126/apex/metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"convention",
1111
"naming"
1212
],
13-
"defaultSeverity": "Blocker",
13+
"defaultSeverity": "Minor",
1414
"ruleSpecification": "RSPEC-8126",
1515
"sqKey": "S8126",
1616
"scope": "Main",
@@ -20,8 +20,8 @@
2020
"quickfix": "unknown",
2121
"code": {
2222
"impacts": {
23-
"MAINTAINABILITY": "BLOCKER"
23+
"MAINTAINABILITY": "LOW"
2424
},
2525
"attribute": "CONVENTIONAL"
2626
}
27-
}
27+
}

rules/S8126/apex/rule.adoc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
This rule raises an issue when a custom exception class does not end with the suffix "Exception" or does not properly extend the Exception class.
1+
This rule raises an issue when a custom exception class does not end with the suffix "Exception" or a class name including "Error" does not extend the Exception class.
22

33
== Why is this an issue?
44

55
Custom exception classes serve as a way to handle specific error conditions in your Apex code. When these classes don't follow proper naming conventions, it creates several problems.
66

7-
First, unclear naming makes code harder to understand and maintain. A class named `MyError` or `CustomHandler` doesn't immediately signal to other developers that it's an exception class. This lack of clarity can lead to confusion when reading or debugging code.
7+
First, unclear naming makes code harder to understand and maintain. A class named ``++MyError++`` doesn't immediately signal to other developers that it's an exception class. This lack of clarity can lead to confusion when reading or debugging code.
88

99
Second, Apex follows Java conventions where exception classes should end with "Exception". This convention is widely recognized and expected by developers. Breaking this convention makes your code inconsistent with established patterns.
1010

@@ -34,18 +34,14 @@ Rename your custom exception class to end with 'Exception' and ensure it properl
3434
----
3535
public class MyError extends Exception {} // Noncompliant
3636
37-
public class CustomHandler extends Exception {} // Noncompliant
38-
3937
public class ValidationIssue extends Exception {} // Noncompliant
4038
----
4139

4240
==== Compliant solution
4341

4442
[source,apex,diff-id=1,diff-type=compliant]
4543
----
46-
public class MyCustomException extends Exception {}
47-
48-
public class CustomProcessException extends Exception {}
44+
public class MyErrorException extends Exception {}
4945
5046
public class ValidationException extends Exception {}
5147
----

0 commit comments

Comments
 (0)