2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2023-02-06 16:01:57 +01:00
|
|
|
include::../description.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2023-02-06 14:10:38 +01:00
|
|
|
|
|
|
|
[source,vbnet]
|
|
|
|
----
|
|
|
|
Public Class FruitException ' Noncompliant - this has nothing to do with Exception
|
|
|
|
Private expected As Fruit
|
|
|
|
Private unusualCharacteristics As String
|
|
|
|
Private appropriateForCommercialExploitation As Boolean
|
|
|
|
' ...
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class CarException ' Noncompliant - does not derive from any Exception-based class
|
2023-02-09 08:37:20 +01:00
|
|
|
Public Sub New(message As String, inner As Exception)
|
2023-02-06 14:10:38 +01:00
|
|
|
' ...
|
|
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2023-02-06 14:10:38 +01:00
|
|
|
|
|
|
|
[source,vbnet]
|
|
|
|
----
|
|
|
|
Public Class FruitSport ' Compliant - class name does not end with 'Exception'
|
|
|
|
Private expected As Fruit
|
|
|
|
Private unusualCharacteristics As String
|
|
|
|
Private appropriateForCommercialExploitation As Boolean
|
|
|
|
' ...
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class CarException Inherits Exception ' Compliant - correctly extends System.Exception
|
2023-02-09 08:37:20 +01:00
|
|
|
Public Sub New(message As String, inner As Exception)
|
2023-02-06 14:10:38 +01:00
|
|
|
MyBase.New(message, inner)
|
|
|
|
' ...
|
|
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
|
|
|
|
----
|
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Message
|
|
|
|
|
|
|
|
Rename this class to remove "Exception" or correct its inheritance.
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2023-02-06 14:10:38 +01:00
|
|
|
endif::env-github,rspecator-view[]
|