Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
No Overload takes 5 arguments
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01583574
Message ID:
01583700
Vues:
36
>>I haven't read this, but is has over 300 reviews and 3.9 stars. http://www.codeproject.com/Articles/9538/Exception-Handling-Best-Practices-in-NET
>
>Do you know what is the purpose of this code? (taken from the link above)
>
>
>try
>{
>    // Some code that throws an exception
>}
>catch (Exception ex)
>{
>    // some code that handles the exception
>    throw;
>}
>
>
>I saw it in many places, but I never understood why would you catch an exception just to throw it again, would't it that the behaviour if you did not have the try in the first place?

I think the catch comment is probably badly worded. If the exception could truly be handled then re-throwing would be unnecessary. If it's only partially handled (eg logging or notifying the user) but is not recoverable then throwing to a higher level makes sense....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform