Using the ValidationException Class

I have a situation where one of our developers wants to set the standard where we lay out System.ComponentModel.DataAnnotations.ValidationExceptions in all our moving forward applications. An example would be if a user enters bad data into a form, and our business logic level throws a ValidationException, which is handled at the calling level.

However, I am concerned that this class of exceptions is used out of context and that one day we will use some dynamic data controls that use this exception, and it will be difficult to tell the difference between when it makes use of ValidationException versus the time that Dynamic Controls throws an exception.

We already use a special exception class called "OurCustomException", and I think it would be better to just subclass it and create the OurCustomValidationException class. Thus, exceptions of different types can be clear.

Any opinions?

+5
source share
1 answer

... it will be difficult to tell the difference between when it makes use of ValidationException vs the time that dynamic controls raise an exception.

I think this is the main point you should look at when making this decision.

, , , ( "" ) - . . ValidationException , , . .

, . CustomException, ValidationException, , . ( , , ).

, ValidationException, , , .

, / (, , ). , , "" ( ), , . , , , ValidationExceptions.

. :

- ValidationException

. , , . :

  • "abc"

1. - / . , , 2. . -. ( "", ), , .

"", () . ( : 1. , "", 2. , , .)

: , .

+9

All Articles