public static ErrorResponse FromException(Exception ex) { var exception = ex; var summary = exception.Message; //if (exception is WebException || exception is SocketException) //{ // // Commonly returned when connections to RavenDB fail // summary = "The Octopus windows service may not be running: " + summary; //} var statusCode = HttpStatusCode.InternalServerError; if (exception is UserException) { statusCode = HttpStatusCode.Accepted; } var error = new ts.dto.Error { ErrorMessage = summary, FullException = exception.ToString() }; // Special cases //if (exception is ResourceNotFoundException) //{ // statusCode = HttpStatusCode.NotFound; // error.FullException = null; //} //if (exception is OctopusSecurityException) //{ // statusCode = HttpStatusCode.Forbidden; // error.FullException = null; //} var response = new ErrorResponse(error); response.StatusCode = statusCode; return(response); }
private ErrorResponse(ts.dto.Error error) : base(error, new DefaultJsonSerializer()) { this.error = error; }