add the extended exception
This commit is contained in:
@ -22,11 +22,9 @@ generateclient_dotnetcore:
|
||||
- INSTANCE_SPECIFIER=`cat instance.txt`
|
||||
- API_MAJOR_VERSION=`cat api_major_version.txt`
|
||||
- API_VERSION=`cat api_version.txt | awk -F- '{print $1}'`
|
||||
- ls -lR output
|
||||
- echo output/src/$CLIENT_PACKAGE_PREFIX.$CI_PROJECT_NAME.$INSTANCE_SPECIFIER.v$API_MAJOR_VERSION/Model/ErrorResultObject.cs
|
||||
- ls -l output/src/$CLIENT_PACKAGE_PREFIX.$CI_PROJECT_NAME.$INSTANCE_SPECIFIER.v$API_MAJOR_VERSION/Model/ErrorResultObject.cs
|
||||
- if [ -f output/src/$CLIENT_PACKAGE_PREFIX.$CI_PROJECT_NAME.$INSTANCE_SPECIFIER.v$API_MAJOR_VERSION/Model/ErrorResultObject.cs ]; then
|
||||
echo "ErrorResultObject.cs exists, start the postprocessing";
|
||||
cat ClientExtApiException.cs | sed -e 's,NAMESPACEPLACEHOLDER,'$CLIENT_PACKAGE_PREFIX.$CI_PROJECT_NAME.$INSTANCE_SPECIFIER.v$API_MAJOR_VERSION',g' > output/src/$CLIENT_PACKAGE_PREFIX.$CI_PROJECT_NAME.$INSTANCE_SPECIFIER.v$API_MAJOR_VERSION/Client;
|
||||
fi
|
||||
- mv output output_dotnetcore
|
||||
|
||||
|
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