Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Throwing the error correctly
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Throwing the error correctly
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01623011
Message ID:
01623011
Vues:
44
Hi everybody,

I have the following code:
conflicts = GetConflicts(sbMax4Sale, cStartTime, cEndTime, max4saleViewModel.DailyLimits);
                            if (conflicts > 0)
                            {
                                throw SetConflictsError(conflicts);

                            }
where SetConflictsError method is the following:
 private HttpResponseException SetConflictsError(int conflicts)
        {
            var response = (conflicts == 1) ? Messages.existingConflict : String.Format(Messages.xExistingConflicts, conflicts);
            return new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content = new StringContent(response),
                ReasonPhrase = response
            });
        }
Originally that code was embedded into main code (e.g. not a separate method) and the error was correctly returned back to the interface (e.g. instead of return I had throw in the main method). Now instead I see the generic error and not this error. Do you know what should I do to be able to separate this logic as I call it in a few places?

Thanks in advance.

Also, I am debugging the code and the error is first shown in the debugger. May be that's the reason as well. But I want to verify if my approach is correct or not and how to have separate method.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform