Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
No Overload takes 5 arguments
Message
De
19/09/2013 09:59:28
 
 
À
19/09/2013 09:17:24
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:
01583629
Vues:
41
J'aime (1)
>>What Craig was suggesting (and obviously he can jump in) is to abandon the idea of output parameters, and use a general try...catch block , which gives you a repeatable approach towards capturing and reporting on errors. It's not that output parameters for error codes don't work - it's just that structured error/exception handling is a better approach. It will mean some re-work on your code and will probably take a bit of time, but in the long run it's worth it.
>
>I actually do have Try/Catch code in the method in order to catch the errors, but notifying the calling method is where I am sticking. When the error occurs I need to catch it but continue trying to send all the other emails and then when the process is complete to display the errors to the user. How should I approach this?

One way:
   public class EmailFailure
    {
        public string ErrorCode { get; set; }
        public string ErrorMessage { get; set; }
    }
Then:
       public static void SendEmails(Guid emailPK, string subject, string html, out List<EmailFailure> failures)
        {
            failures = new List<EmailFailure>();
            //Iterate email list.  When you hit a problem email:
            failures.Add(new EmailFailure { ErrorCode = "123", ErrorMessage = "Bugger" });
        }
Calling:
          List<EmailFailure> failures;
            SendEmails(Guid.Empty, "Testing", "html", out failures);
            foreach (EmailFailure f in failures)
            {
                //Display
            }
but still raise an exception for anything not handled in the above.....
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform