diff --git a/ClientExtApiException.cs b/ClientExtApiException.cs index c6169ed..c6affe6 100644 --- a/ClientExtApiException.cs +++ b/ClientExtApiException.cs @@ -1,23 +1,49 @@ -#pragma warning disable 1591 - - using System; using NAMESPACEPLACEHOLDER.Model; using Newtonsoft.Json; - namespace NAMESPACEPLACEHOLDER.Client { + /// + /// 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. + /// public class ExtApiException: ApiException { + /// + /// ErrorCode, this is the http code returned by the webservice + /// readonly property + /// public int ErrorCode { get; } + /// + /// ServiceErrorCode, this is the service specific error code, compare to the + /// serviceErrorCodes.yaml in the webservice project + /// readonly property + /// public int ServiceErrorCode { get; } + /// + /// OffensiveData, repeats the data sent to the webservice which led to this + /// particular error + /// readonly property + /// public String OffensiveData { get; } - + public ExtApiException(ErrorResultObject ero): base(ero.errorCode, ero.errorMessage, ero) { ErrorCode = ero.errorCode; ServiceErrorCode = ero.serviceErrorCode; OffensiveData = ero.offensiveData; } - + + /// + /// 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. + /// public static ExceptionFactory ExtExceptionFactory = (methodName, response) => { return (((int)response.StatusCode) >= 400) ? new ExtApiException(JsonConvert.DeserializeObject(response.RawContent)) : null; }; @@ -25,4 +51,3 @@ namespace NAMESPACEPLACEHOLDER.Client { } -#pragma warning restore 1591