34 lines
981 B
C#
34 lines
981 B
C#
#pragma warning disable 1591
|
|
|
|
|
|
using System;
|
|
using NAMESPACEPLACEHOLDER.Model;
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
namespace NAMESPACEPLACEHOLDER.Client {
|
|
public 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
|