Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Throwing the error correctly
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Throwing the error correctly
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01623011
Message ID:
01623011
Views:
43
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
Reply
Map
View

Click here to load this message in the networking platform