add the extended exception
This commit is contained in:
33
ClientExtApiException.cs
Normal file
33
ClientExtApiException.cs
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma warning disable 1591
|
||||
|
||||
|
||||
using System;
|
||||
using NAMESPACEPLACEHOLDER.Model;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace NAMESPACEPLACEHOLDER.Client {
|
||||
class ExtApiException: ApiException {
|
||||
public int ErrorCode { get; }
|
||||
public int ServiceErrorCode { get; }
|
||||
public String OffensiveData { get; }
|
||||
|
||||
public ExtApiException(ErrorResultObject ero): base(ero.errorCode, ero.errorMessage, ero) {
|
||||
ErrorCode = ero.errorCode;
|
||||
ServiceErrorCode = ero.serviceErrorCode;
|
||||
OffensiveData = ero.offensiveData;
|
||||
}
|
||||
|
||||
public static ExceptionFactory ExtExceptionFactory = (methodName, response) => {
|
||||
var status = (int) response.StatusCode;
|
||||
if (status >= 400) {
|
||||
var ero = JsonConvert.DeserializeObject<ErrorResultObject>(response.RawContent);
|
||||
return new ExtApiException(ero);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma warning restore 1591
|
Reference in New Issue
Block a user