diff --git a/Factories/RestSharpFactory.cs b/Factories/RestSharpFactory.cs index 8a52d947..1eb9d456 100644 --- a/Factories/RestSharpFactory.cs +++ b/Factories/RestSharpFactory.cs @@ -43,7 +43,7 @@ public RestSharpFactory(string BaseUrl, string Account, string Password) || response.StatusCode == HttpStatusCode.Forbidden || response.StatusCode == 0) { - var Exception = new ApplicationException(response.Content + " " + response.ErrorMessage, response.ErrorException); + var Exception = new PrestaSharpException(response.Content, response.ErrorMessage, response.StatusCode, response.ErrorException); throw Exception; } return response.Data; @@ -88,7 +88,7 @@ public RestSharpFactory(string BaseUrl, string Account, string Password) || response.StatusCode == HttpStatusCode.Forbidden || response.StatusCode == 0) { - var Exception = new ApplicationException(response.Content + " " + response.ErrorMessage, response.ErrorException); + var Exception = new PrestaSharpException(response.Content, response.ErrorMessage, response.StatusCode, response.ErrorException); throw Exception; } return response.Data; diff --git a/PrestaSharp.csproj b/PrestaSharp.csproj index 64c3f206..1496118c 100644 --- a/PrestaSharp.csproj +++ b/PrestaSharp.csproj @@ -116,6 +116,7 @@ + diff --git a/PrestaSharpException.cs b/PrestaSharpException.cs new file mode 100644 index 00000000..aa5e3612 --- /dev/null +++ b/PrestaSharpException.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace PrestaSharp +{ + public class PrestaSharpException : ApplicationException + { + public HttpStatusCode ResponseHttpStatusCode { get; set; } + public string ResponseContent { get; set; } + public string ResponseErrorMessage { get; set; } + + public PrestaSharpException() + : base() + { + } + + public PrestaSharpException(string ResponseContent, string ResponseErrorMessage, Exception ResponseErrorException) + : base(ResponseContent + " " + ResponseErrorMessage, ResponseErrorException) + { + this.ResponseContent = ResponseContent; + this.ResponseErrorMessage = ResponseErrorMessage; + } + + public PrestaSharpException(string ResponseContent, string ResponseErrorMessage, HttpStatusCode ResponseHttpStatusCode, Exception ResponseErrorException) + : base(ResponseContent + " " + ResponseErrorMessage + " HttpStatusCode: " + ResponseHttpStatusCode, ResponseErrorException) + { + this.ResponseContent = ResponseContent; + this.ResponseErrorMessage = ResponseErrorMessage; + this.ResponseHttpStatusCode = ResponseHttpStatusCode; + } + + } +} diff --git a/README.md b/README.md index 273ca363..1d278f8e 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ PrestaSharp is GNU General Public License (GPL) This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantabilty or fitness for a particular purpose. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -Copyright (C) 2013 Bukimedia +Copyright (C) 2014 Bukimedia - Bukimedia: http://www.bukimedia.com/ - Twitter: http://twitter.com/bukimedia - GitHub: https://github.com/bukimedia \ No newline at end of file