Skip to content

Commit

Permalink
Added PrestaSharpException
Browse files Browse the repository at this point in the history
  • Loading branch information
EduLeonPavon committed Apr 14, 2014
1 parent 2ce504a commit 891c63d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Factories/RestSharpFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions PrestaSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<Compile Include="Factories\ProductFactory.cs" />
<Compile Include="Factories\RestSharpFactory.cs" />
<Compile Include="Lib\Functions.cs" />
<Compile Include="PrestaSharpException.cs" />
<Compile Include="Serializers\PrestaSharpSerializer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Entities\shop.cs" />
Expand Down
37 changes: 37 additions & 0 deletions PrestaSharpException.cs
Original file line number Diff line number Diff line change
@@ -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;
}

}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://www.gnu.org/licenses/>.

Copyright (C) 2013 Bukimedia
Copyright (C) 2014 Bukimedia
- Bukimedia: http://www.bukimedia.com/
- Twitter: http://twitter.com/bukimedia
- GitHub: https://github.com/bukimedia

0 comments on commit 891c63d

Please sign in to comment.