Hello ,
I am defining a new attribute for validation purposes ,in case the
validation of the object which has specific attribute not passing well
which kind of exception should I throw? (kind of Ilegal state,is there
an already defined format for it?)
Thank you!
Ignacio Machin ( .NET/ C# MVP ) - 09 Apr 2008 20:59 GMT
> Hello ,
> I am defining a new attribute for validation purposes ,in case the
[quoted text clipped - 4 lines]
>
> *** Sent via Developersdexhttp://www.developersdex.com***
Depends, you can create your own exception if you want. Take a look at
the exceptions deriving from either Exception or ApplicationException
to see if there is one that fits your case
csharpula csharp - 10 Apr 2008 14:04 GMT
Thanks but the question is if there is any kind of already defined
exception I should use in this case.
Ignacio Machin ( .NET/ C# MVP ) - 10 Apr 2008 18:40 GMT
> Thanks but the question is if there is any kind of already defined
> exception I should use in this case.
>
> *** Sent via Developersdexhttp://www.developersdex.com***
Hum,
Frankly I do not know. it would be nice to have a program that given a
type you get all the derived types and/or what types implement it.
Does anybody knows such a tool?
Marc Gravell - 10 Apr 2008 20:22 GMT
> Does anybody knows such a tool?
Reflector
Chris Crowther MBCS - 10 Apr 2008 14:20 GMT
> I am defining a new attribute for validation purposes ,in case the
> validation of the object which has specific attribute not passing well
> which kind of exception should I throw? (kind of Ilegal state,is there
> an already defined format for it?)
I'd look at ArgumentException. Though I'm not entirely clear from your
post whether it actually is an argument you're testing; if it's not you
might be better off creating your own derived Exception.

Signature
Chris Crowther MBCS
C# Developer
RHD Research Ltd
Marc Gravell - 10 Apr 2008 14:25 GMT
InvalidOperationException goes some of the way...
Marc