Click here to Skip to main content
15,909,051 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionXML parser which uses XML schema Pin
yvek6-Feb-09 1:21
yvek6-Feb-09 1:21 
AnswerRe: XML parser which uses XML schema Pin
Curtis Schlak.25-Feb-09 8:42
Curtis Schlak.25-Feb-09 8:42 
QuestionWhat is Sync block index ? Pin
Yanshof5-Feb-09 8:12
Yanshof5-Feb-09 8:12 
AnswerRe: What is Sync block index ? Pin
harold aptroot5-Feb-09 11:01
harold aptroot5-Feb-09 11:01 
AnswerRe: What is Sync block index ? Pin
Alan N5-Feb-09 11:55
Alan N5-Feb-09 11:55 
AnswerRe: What is Sync block index ? Pin
Jon Rista6-Feb-09 9:32
Jon Rista6-Feb-09 9:32 
AnswerRe: What is Sync block index ? Pin
mailhacker28-Mar-10 23:51
mailhacker28-Mar-10 23:51 
QuestionGeneric exception handlers: clever idea or bad idea Pin
supercat94-Feb-09 11:59
supercat94-Feb-09 11:59 
One difficulty with the normal exception system is that while it allows applications to use catch exceptions from which other exceptions are inherited, the normal exception hierarchy is based upon what type of problem occurred, rather than upon what the problem 'means'. An TimeoutException that occurs in one circumstance should probably be handled totally differently from one that occurs in another.

Although .Net allows one to define a custom hierarchy for one's own exceptions, each exception class needs to repeat the code for the four standard New() methods, and so creating a significant number of classes can be a nuisance.

One approach which would seem to hold some promise would be for an application to express its own exceptions using generic classes, something like:
Class GenEx
  Inherits Exception
  ... New() methods here 
End Class

Class GenEx(of T)
  Inherits GenEx
  ... New() methods here 
End Class

Class GenEx(of T, U)
  Inherits GenEx(of T)
  ... New() methods here 
End Class

Class GenEx(of T, U, V)
  Inherits GenEx(of T, U)
  ... New() methods here 
End Class

etc. if more nesting is desired.


Then if an object of type MyThing wants to throw an exception for a timeout condition, it can throw a New GenEx(of MyThing, TimeoutException) which can be caught by a Catch of either GenEx, GenEx(of MyThing), or GenEx(of MyThing, TimeoutException).

Things get a little clunky if MyThing is itself an inherited class; catch statements for GenEx(of MyThingsParent) won't catch a throw of type GenEx(of MyThing). In designing the throw statements for MyThing, however, one could throw a GenEx(of MyThingsParent, MyThing, TimeoutException) [though that would unfortunately only get snagged by a Catch of GenEx(of MyThingsParent) and not one of GenEx(of MyThingsParent, TimeoutException)] or a GenEx(of MyThingsParent, MyThing, TimeoutException) [ignoring the actual type of MyThing].

Has anyone else tried anything at all similar to this approach? With what effects (good or bad)?

Pro: it would facilitate a more useful exception hierarchy based upon the type of object trying to do something than upon the nature of the result.

Con: unless one had a procedure for cataloging the exceptions one was actually using, it could turn into a real mess.

Any thoughts?
AnswerRe: Generic exception handlers: clever idea or bad idea Pin
PIEBALDconsult5-Feb-09 15:38
mvePIEBALDconsult5-Feb-09 15:38 
GeneralRe: Generic exception handlers: clever idea or bad idea Pin
supercat95-Feb-09 18:55
supercat95-Feb-09 18:55 
GeneralRe: Generic exception handlers: clever idea or bad idea Pin
Gideon Engelberth6-Feb-09 3:22
Gideon Engelberth6-Feb-09 3:22 
GeneralRe: Generic exception handlers: clever idea or bad idea Pin
Mark Churchill8-Feb-09 14:44
Mark Churchill8-Feb-09 14:44 
AnswerRe: Generic exception handlers: clever idea or bad idea Pin
Vasudevan Deepak Kumar10-Feb-09 3:12
Vasudevan Deepak Kumar10-Feb-09 3:12 
QuestionHow to run a password protected SSIS package using VB.NET Pin
CodalcoholicNBrainy4-Feb-09 2:22
CodalcoholicNBrainy4-Feb-09 2:22 
Question[Message Deleted] Pin
imnotso#3-Feb-09 23:59
imnotso#3-Feb-09 23:59 
AnswerRe: WebUIValidation.js and .NET 2.0 upgrade. Pin
Not Active4-Feb-09 1:18
mentorNot Active4-Feb-09 1:18 
GeneralRe: WebUIValidation.js and .NET 2.0 upgrade. Pin
imnotso#4-Feb-09 1:20
imnotso#4-Feb-09 1:20 
GeneralRe: WebUIValidation.js and .NET 2.0 upgrade. Pin
Colin Angus Mackay5-Feb-09 12:35
Colin Angus Mackay5-Feb-09 12:35 
GeneralRe: WebUIValidation.js and .NET 2.0 upgrade. Pin
imnotso#5-Feb-09 22:57
imnotso#5-Feb-09 22:57 
GeneralRe: WebUIValidation.js and .NET 2.0 upgrade. Pin
Colin Angus Mackay5-Feb-09 23:23
Colin Angus Mackay5-Feb-09 23:23 
GeneralRe: WebUIValidation.js and .NET 2.0 upgrade. Pin
imnotso#5-Feb-09 23:35
imnotso#5-Feb-09 23:35 
QuestionThe specified module could not be found. (Exception from HRESULT: 0x8007007E [modified] Pin
tsanthosh3-Feb-09 22:42
tsanthosh3-Feb-09 22:42 
QuestionHi guys - is it possible to cast generic up the specific types hierarchy??? Pin
netguruMelb3-Feb-09 20:59
netguruMelb3-Feb-09 20:59 
AnswerRe: Hi guys - is it possible to cast generic up the specific types hierarchy??? Pin
Gideon Engelberth4-Feb-09 3:33
Gideon Engelberth4-Feb-09 3:33 
AnswerRe: Hi guys - is it possible to cast generic up the specific types hierarchy??? Pin
supercat94-Feb-09 5:17
supercat94-Feb-09 5:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.