0

I throw unhandled DataServiceExceptions (they are handled by WCF automatically) to return status codes for unauthorised access etc. How do I prevent Visual Studio from breaking at these unhandled exceptions?

if (!System.Web.Security.Roles.IsUserInRole("Users"))
        {
            throw new DataServiceException((int)HttpStatusCode.Unauthorized, "You do not have access to this resource.");
        }
Monstieur
  • 7,992
  • 10
  • 51
  • 77
  • "I use unhandled DataServiceExceptions", "they are handled by WCF automatically", "from breaking at these unhandled exceptions". So basically you are handling it or not? Are you catching it on catch statement? or just throwing it? – Pawan Nogariya Feb 20 '13 at 07:08
  • please update your code... – felix Antony Feb 20 '13 at 07:28
  • I simply throw new DataServiceException(401, "Error..."). WCF automatically unwraps it and sends the formatted error message to the client, but Visual Studio still breaks at the line in my code. There is no try..catch at all. – Monstieur Feb 20 '13 at 07:42

1 Answers1

0

Can you add a DebuggerNonUserCode attribute

or you could tell visual studio to ignore the exception type, as in: How to tell the debugger to ignore breaking on thrown exceptions?

Community
  • 1
  • 1
Matt Whetton
  • 6,616
  • 5
  • 36
  • 57
  • Can't attributes only be applied to an entire method or class? I still want it to break if there's another exception in the previous or following lines. – Monstieur Feb 20 '13 at 08:38