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

.NET (Core and Framework)

 
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 
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 
I just haven't yet thought of a use for it.

Well, one use is to reduce the amount of copy/pasted code for custom exceptions. Not in and of itself sufficient reason to use a new pattern, though if using a wider range of exceptions is helpful and the reduced copy/paste requirement would encourages such practices, that could be a good thing.

More generally, it seems to me that there are many situations where a routine's caller will sometimes want to know the specifics of something that went wrong, and others where the caller's concern is simply whether or not it worked. For example, if I send a request for information to another machine and I don't get a valid reply, there are a number of things that could have gone wrong (note that the protocol is designed for communicating with an embeded system via serial or TCP, so it includes its own sequence numbers, checksums, etc. to allow for the possibility of dropped or garbled bytes):

  1. Connection attempt failed at transport layer
  2. Connection died at transport layer
  3. No response received
  4. Garbage packet received
  5. Valid-seeming packet received, but with wrong sequence number
  6. Valid packet received indicating remote end received out-of-sequence packet
  7. Valid packet: "Command unknown"
  8. Valid packet: "Credentials refused"
  9. Valid packet: "Command invalid in this context"
  10. Valid packet, but not the expected type
  11. Valid packet, but not the expected length


In some cases, if a command/reply exchange fails, it won't really matter why, and it will make sense to just catch a generic 'something went wrong while exchanging packets' exception. In others, different exception causes should be handled differently. At that level (send/receive one packet), basic inheritance would suffice, though copying/pasting code for all the different exceptions would be annoying.

At a higher level, though, the effective meaning of the above errors may depend upon what the system was doing when it occurred. If certain exceptions happen on certain commands, for example, the system should probably try to re-establish synchronization with the remote machine as soon as possible. In other case, that wouldn't be helpful.

Thinking about it, perhaps the best trick wouldn't be to use nested generic exceptions, but rather to take advantage of the 'When' clause in VB.net; if a custom exception class contains an integer with a bitmask enumeration type, then an exception handler could test for any combination of flags without requiring any hierarchical relationship. Maybe that would be the best approach. I wonder if there would be any adverse performance consequences.
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 
QuestionFinding a given day or weekday x months from today Pin
nzmike3-Feb-09 14:34
nzmike3-Feb-09 14:34 
GeneralRe: Finding a given day or weekday x months from today Pin
Luc Pattyn3-Feb-09 16:13
sitebuilderLuc Pattyn3-Feb-09 16:13 

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.