drop ext excp, moved to common-ci

This commit is contained in:
Wolfgang Hottgenroth
2021-12-10 16:55:14 +01:00
parent 700008e27b
commit f0c1412d2d

View File

@ -1,56 +0,0 @@
using System;
using NAMESPACEPLACEHOLDER.Model;
using Newtonsoft.Json;
namespace NAMESPACEPLACEHOLDER.Client {
/// <summary>
/// Extended API Exception, provides ErrorCode (http code), ServiceErrorCode (service
/// specific error code), status message (via super class ApiException), help link
/// (also via super class ApiException) and offensive data via properties of the exception
/// itself.
/// Usually when openapi specificiation provided ErrorResultObject type for endpoints
/// which returns an object of that type in case of errors greater or equal then 400,
/// in particular for 400 and 500.
/// To use this Extended API Exception set the ExceptionFactory immediately after
/// instantiating the API object to ExtApiException.ExtExceptionFactory.
/// </summary>
public class ExtApiException: ApiException {
/// <summary>
/// ErrorCode, this is the http code returned by the webservice
/// readonly property
/// </summary>
public int ErrorCode { get; }
/// <summary>
/// ServiceErrorCode, this is the service specific error code, compare to the
/// serviceErrorCodes.yaml in the webservice project
/// readonly property
/// </summary>
public int ServiceErrorCode { get; }
/// <summary>
/// OffensiveData, repeats the data sent to the webservice which led to this
/// particular error
/// readonly property
/// </summary>
public String OffensiveData { get; }
/// <summary>
/// Constructor of the ExtApiException, only to be used by the below factory method
/// </summary>
private ExtApiException(ErrorResultObject ero): base(ero.errorCode, ero.errorMessage, ero) {
ErrorCode = ero.errorCode;
ServiceErrorCode = ero.serviceErrorCode;
OffensiveData = ero.offensiveData;
}
/// <summary>
/// ExceptionFactory to transform the http response of errors from the webservice into the
/// ExtApiException
/// Set it immediately after instantiating the API object within the new object.
/// </summary>
public static ExceptionFactory ExtExceptionFactory = (methodName, response) => {
return (((int)response.StatusCode) >= 400) ? new ExtApiException(JsonConvert.DeserializeObject<ErrorResultObject>(response.RawContent)) : null;
};
}
}