gocardless / gocardless-legacy-dotnet

The .NET client library for the GoCardless Legacy API
https://nuget.org/packages/GoCardless/
MIT License
12 stars 15 forks source link

Add HttpStatusCode property to ApiException #24

Open oobayly opened 10 years ago

oobayly commented 10 years ago

Rather than parsing the response message for string values, which is subject to the message changing in later versions, I recommend adding a StatusCode property to the ApiException class.

I'd submit a diff for all the changes, but unfortunately I've had to make a lot of changes to get it running in .Net 3.5, so the diffs wouldn't be valid. In short, just set the StatusCode property everywhere where the ApiException is created.

--- GoCardlessSdk\Exceptions.cs.old 2013-06-04 09:37:26.000000000 +0100
+++ GoCardlessSdk\Exceptions.cs 2013-11-12 14:52:33.325566900 +0000
@@ -11,6 +11,8 @@
         public JObject Content { get; set; }

         public string RawContent { get; set; }
+
+        public System.Net.HttpStatusCode StatusCode { get; set; }
     }
     public class ClientException : Exception
     {