Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions OpenAPI Client/Exception/BasicApiException.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@

using System.Net;

namespace Bol.OpenAPI.Exception
{
public class BasicApiException : System.ApplicationException
{
public HttpStatusCode StatusCode { get; set; }
public string Status { get; set; }

public BasicApiException() { }

public BasicApiException(string status, string message) : base(message)
{
this.Status = status;
}
public BasicApiException(HttpStatusCode statusCode, string status, string message) : base(message)
{
StatusCode = statusCode;
Status = status;
}

public override string ToString()
{
return $"[{StatusCode} {Status} {Message}]";
}
}
}
2 changes: 1 addition & 1 deletion OpenAPI Client/Exception/Handler/ExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static BasicApiException HandleBasicApiException(HttpWebResponse response
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
string responseString = reader.ReadToEnd();
Error error = JsonConvert.DeserializeObject<Error>(responseString);
return new BasicApiException(error.Code, error.Message);
return new BasicApiException(response.StatusCode, error.Code, error.Message);
}
}
}
Expand Down