using System;
using System.Net;
namespace Firebase.Database {
public class FirebaseException : Exception {
public FirebaseException(string requestUrl, string requestData, string responseData, HttpStatusCode statusCode)
: base(GenerateExceptionMessage(requestUrl, requestData, responseData)) {
RequestUrl = requestUrl;
RequestData = requestData;
ResponseData = responseData;
StatusCode = statusCode;
}
public FirebaseException(string requestUrl, string requestData, string responseData, HttpStatusCode statusCode,
Exception innerException)
: base(GenerateExceptionMessage(requestUrl, requestData, responseData), innerException) {
RequestUrl = requestUrl;
RequestData = requestData;
ResponseData = responseData;
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}";
}
}
}