documentation
This commit is contained in:
@ -1,23 +1,49 @@
|
|||||||
#pragma warning disable 1591
|
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using NAMESPACEPLACEHOLDER.Model;
|
using NAMESPACEPLACEHOLDER.Model;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
|
||||||
namespace NAMESPACEPLACEHOLDER.Client {
|
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 {
|
public class ExtApiException: ApiException {
|
||||||
|
/// <summary>
|
||||||
|
/// ErrorCode, this is the http code returned by the webservice
|
||||||
|
/// readonly property
|
||||||
|
/// </summary>
|
||||||
public int ErrorCode { get; }
|
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; }
|
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; }
|
public String OffensiveData { get; }
|
||||||
|
|
||||||
public ExtApiException(ErrorResultObject ero): base(ero.errorCode, ero.errorMessage, ero) {
|
public ExtApiException(ErrorResultObject ero): base(ero.errorCode, ero.errorMessage, ero) {
|
||||||
ErrorCode = ero.errorCode;
|
ErrorCode = ero.errorCode;
|
||||||
ServiceErrorCode = ero.serviceErrorCode;
|
ServiceErrorCode = ero.serviceErrorCode;
|
||||||
OffensiveData = ero.offensiveData;
|
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) => {
|
public static ExceptionFactory ExtExceptionFactory = (methodName, response) => {
|
||||||
return (((int)response.StatusCode) >= 400) ? new ExtApiException(JsonConvert.DeserializeObject<ErrorResultObject>(response.RawContent)) : null;
|
return (((int)response.StatusCode) >= 400) ? new ExtApiException(JsonConvert.DeserializeObject<ErrorResultObject>(response.RawContent)) : null;
|
||||||
};
|
};
|
||||||
@ -25,4 +51,3 @@ namespace NAMESPACEPLACEHOLDER.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
|
||||||
|
Reference in New Issue
Block a user