Re: Possible TRY...CATCH...END TRY
From: Nay Myo Aung (noemail_at_noserver.com)
Date: 12/03/04
- Next message: Nay Myo Aung: "Re: Possible TRY...CATCH...END TRY"
- Previous message: Madhu[C#-MVP]: "Re: App.config question. Me is stuck good :-("
- In reply to: Cor Ligthert: "Re: Possible TRY...CATCH...END TRY"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Possible TRY...CATCH...END TRY"
- Reply: Herfried K. Wagner [MVP]: "Re: Possible TRY...CATCH...END TRY"
- Reply: Daniel Jin: "Re: Possible TRY...CATCH...END TRY"
- Reply: Larry Serflaten: "Re: Possible TRY...CATCH...END TRY"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 4 Dec 2004 01:24:29 +1300
Hi Cor,
Actually, it is not endless. We could put counters or we could have
something like ReTry(3) for 3 retries, as pointed out by Rakesh Rajan.
The main idea is to eliminate the need to rewrite the code that is already
written in the Try block with only a small variation (small enough to be
defined through variables).
For instance...
Try
<<TaskA>>
Catch
Try
<<TaskA with small variation>>
Catch
Try
<<TaskA with another small variation>>
Catch
Try
<<TaskA with yet another small variation>>
Catch
End Try
End Try
End Try
End Try
In above example, we need to duplicate the code written in Try block into
sub-Try blocks with just small variations. I consider this as a bad practice
since more code duplication means, more errors and more maintenance
overhead. That's why we need a ReTry statement.
I know we can put the reusable code into Sub procedures but sometimes the
code is not big enough (or not worth the system overhead) to put it in its
own procedure.
-- Nay Myo Aung Chief Visual Software Architect MCP MCSD MCDBA Email: owN0SPAMner @naymyoauN0SPAMng.name [remove NOSPAM s] Homepage: http://hyperdisc.unitec.ac.nz/postgrad/aungn01/ "Cor Ligthert" <notmyfirstname@planet.nl> wrote in message news:%2331sudS2EHA.1408@TK2MSFTNGP10.phx.gbl... > Nay, > > Why would you endless have to catch an error is one them not more than > enough > > The only thing where I can now see where it can be used is in spaghetti > code. > (And your proposal would than be a legalizing of that) > > You are not the first one by the way who contributes this to the > language.vb newsgroup. > > Just my thought > > > Cor > > > "Nay Myo Aung" <owNOspaMnerATnaymyoauNOspaMng.name> > >> Hi All! >> >> I think I discovered a possible improvement on .NET Framwork's >> TRY...CATCH...END TRY statement. I guess most developers might also have >> been discovered that at some point in their .NET development process but >> continued to ignore the problem due to their workloads. >> >> The word is RETRY. >> >> Consider the following... >> >> Try >> >> '...something >> >> Catch e as FileNotFoundException >> >> 'correct the error and then >> ReTry >> >> Catch e2 as DirectoryNotFoundException >> >> 'correct the error and then >> ReTry >> >> Catch e3 as DriveNotFoundException >> >> 'correct the error and then >> ReTry >> >> Catch '<< catch 'unknown' error >> >> 'log the error >> >> Finally >> >> End Try >> >> We .NET programmers could use the keyword RETRY in the any of the Catch >> block to re-execute the code in Try block. If there's another exception >> thrown, we can evaulate that exception in one of the many Catch blocks >> until it reached to the 'unkown' exception. >> >> So, I propose that a new keyword ReTry should be incorporated in the .NET >> Framework 2 as an improvement. >> >> Feel free to feedback on the idea... >> >> -- >> Nay Myo Aung >> Chief Visual Software Architect >> MCP MCSD MCDBA >> >> Email: owN0SPAMner @naymyoauN0SPAMng.name [remove NOSPAM s] >> Homepage: http://hyperdisc.unitec.ac.nz/postgrad/aungn01/ >> > >
- Next message: Nay Myo Aung: "Re: Possible TRY...CATCH...END TRY"
- Previous message: Madhu[C#-MVP]: "Re: App.config question. Me is stuck good :-("
- In reply to: Cor Ligthert: "Re: Possible TRY...CATCH...END TRY"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Possible TRY...CATCH...END TRY"
- Reply: Herfried K. Wagner [MVP]: "Re: Possible TRY...CATCH...END TRY"
- Reply: Daniel Jin: "Re: Possible TRY...CATCH...END TRY"
- Reply: Larry Serflaten: "Re: Possible TRY...CATCH...END TRY"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|