Currently, I'm doing the following to send error messages back to the client:
HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.Forbidden)
{
ReasonPhrase = "No rights to access this resource",
};
throw new HttpResponseException(message);
However, I would like to improve the response further by sending back custom exceptions. So I can have something like this:
public class MyAppException : Exception {}
public class NoRightsException : MyAppException {}
public class SaveException : MyAppException {}
//etc...
All my exceptions will be in a separate assembly that will be reference by both the server and the client.
How is the best to return these exceptions to the client and how will the client have to check whether the response is my custom exception, another exception or simply a text message?