namespace Firebase.Database
{
using System;
using System.Net;
public class FirebaseException : Exception
{
public FirebaseException(string requestUrl, string requestData, string responseData, HttpStatusCode statusCode)
: base(GenerateExceptionMessage(requestUrl, requestData, responseData))
{
this.RequestUrl = requestUrl;
this.RequestData = requestData;
this.ResponseData = responseData;
this.StatusCode = statusCode;
}
public FirebaseException(string requestUrl, string requestData, string responseData, HttpStatusCode statusCode, Exception innerException)
: base(GenerateExceptionMessage(requestUrl, requestData, responseData), innerException)
{
this.RequestUrl = requestUrl;
this.RequestData = requestData;
this.ResponseData = responseData;
this.StatusCode = statusCode;
}
///
/// Post data passed to the authentication service.
///
public string RequestData
{
get;
}
///
/// Original url of the request.
///
public string RequestUrl
{
get;
}
///
/// Response from the authentication service.
///
public string ResponseData
{
get;
}
///
/// Status code of the response.
///
public HttpStatusCode StatusCode
{
get;
}
private static string GenerateExceptionMessage(string requestUrl, string requestData, string responseData)
{
return $"Exception occured while processing the request.\nUrl: {requestUrl}\nRequest Data: {requestData}\nResponse: {responseData}";
}
}
}