12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Net;
- namespace OSHttpServer.Exceptions
- {
- /// <summary>
- /// All HTTP based exceptions will derive this class.
- /// </summary>
- public class HttpException : Exception
- {
- private readonly HttpStatusCode _code;
- /// <summary>
- /// Create a new HttpException
- /// </summary>
- /// <param name="code">http status code (sent in the response)</param>
- /// <param name="message">error description</param>
- public HttpException(HttpStatusCode code, string message) : base(code + ": " + message)
- {
- _code = code;
- }
- /// <summary>
- /// Create a new HttpException
- /// </summary>
- /// <param name="code">http status code (sent in the response)</param>
- /// <param name="message">error description</param>
- /// <param name="inner">inner exception</param>
- public HttpException(HttpStatusCode code, string message, Exception inner)
- : base(code + ": " + message, inner)
- {
- _code = code;
- }
- /// <summary>
- /// status code to use in the response.
- /// </summary>
- public HttpStatusCode HttpStatusCode
- {
- get { return _code; }
- }
- }
- }
|