From e6181c24124d97f2fbc932b8a68311e625463156 Mon Sep 17 00:00:00 2001 From: uzvkl Date: Tue, 11 Jun 2019 23:05:52 +0200 Subject: Move dsa related stuff to subfolder --- dsa/FireBase/FirebaseException.cs | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dsa/FireBase/FirebaseException.cs (limited to 'dsa/FireBase/FirebaseException.cs') diff --git a/dsa/FireBase/FirebaseException.cs b/dsa/FireBase/FirebaseException.cs new file mode 100644 index 0000000..cfc09d3 --- /dev/null +++ b/dsa/FireBase/FirebaseException.cs @@ -0,0 +1,53 @@ +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}"; + } + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2