HttpServiceException
The exception thrown when call to Http server failed (e.g. WebApi or Kepler). This class cannot be inherited.
using System;
using System.Net;
using System.Runtime.Serialization;
namespace Relativity.DataExchange
{
[Serializable]
public sealed class HttpServiceException : Exception
{
public const bool DefaultFatalValue = false;
public const HttpStatusCode DefaultHttpStatusCode = HttpStatusCode.InternalServerError;
public bool Fatal { get; }
public HttpStatusCode StatusCode { get; }
public HttpServiceException()
{
Fatal = false;
StatusCode = HttpStatusCode.InternalServerError;
}
public HttpServiceException(string message)
: base(message)
{
Fatal = false;
StatusCode = HttpStatusCode.InternalServerError;
}
public HttpServiceException(string message, bool fatal)
: this(message, HttpStatusCode.InternalServerError, fatal)
{
}
public HttpServiceException(string message, HttpStatusCode statusCode, bool fatal)
: base(message)
{
StatusCode = statusCode;
Fatal = fatal;
}
public HttpServiceException(string message, Exception innerException)
: base(message, innerException)
{
StatusCode = HttpStatusCode.InternalServerError;
Fatal = false;
}
public HttpServiceException(string message, Exception innerException, bool fatal)
: this(message, innerException, HttpStatusCode.InternalServerError, fatal)
{
}
public HttpServiceException(string message, Exception innerException, HttpStatusCode statusCode, bool fatal)
: base(message, innerException)
{
Fatal = fatal;
StatusCode = statusCode;
}
private HttpServiceException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Fatal = info.GetBoolean("Fatal");
StatusCode = (HttpStatusCode)info.GetValue("StatusCode", typeof(HttpStatusCode));
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException("info");
info.AddValue("Fatal", Fatal);
info.AddValue("StatusCode", StatusCode);
base.GetObjectData(info, context);
}
}
}