I’m wondering how to write documentation comments for HttpResponseException exceptions thrown by ASP.NET Web API controllers? The thing is that, normally you throw a different kind of exception for each case and hence write a documentation comment for each exception type, e.g /// <exception cref="ResourceNotFound">Resource not found</exception>. However, with HttpResponseException, the StatusCode property of the exception is what identifies the error case.
How should I document each of the cases where HttpResponseException may be thrown, each identified by a status code, corresponding to how you otherwise write an /// <exception></exception> comment per exception type?
I’ve found a solution that lets me document error cases in Web API controller methods as one does for normal C# exceptions – map each HTTP status code you want to use for flagging errors to a subclass of
HttpResponseException. This solves my particular problem, which was just down to describing error cases in the documentation comments of Web API controller methods.Consider the following code as an example: