From 9362b491736bbc8eb39a663889188e60c1b98a18 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Mon, 10 Jul 2023 22:54:29 -0400 Subject: [PATCH] added event for errors (#16057) --- .../languages/CSharpClientCodegen.java | 1 + .../generichost/ExceptionEventArgs.mustache | 24 ++ .../OnErrorDefaultImplementation.mustache | 3 +- .../csharp/libraries/generichost/api.mustache | 17 +- .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 20 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 60 +++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 300 +++++++++++++++--- .../Api/FakeClassnameTags123Api.cs | 20 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 180 +++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 80 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 160 ++++++++-- .../Client/ExceptionEventArgs.cs | 24 ++ .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 20 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 60 +++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 300 +++++++++++++++--- .../Api/FakeClassnameTags123Api.cs | 20 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 180 +++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 80 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 160 ++++++++-- .../Client/ExceptionEventArgs.cs | 24 ++ .../.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/DefaultApi.cs | 20 +- .../Client/ExceptionEventArgs.cs | 24 ++ .../.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/DefaultApi.cs | 20 +- .../Client/ExceptionEventArgs.cs | 24 ++ .../.openapi-generator/FILES | 1 + .../src/Org.OpenAPITools/Api/DefaultApi.cs | 20 +- .../Client/ExceptionEventArgs.cs | 24 ++ .../.openapi-generator/FILES | 1 + .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 20 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 60 +++- .../src/Org.OpenAPITools/Api/FakeApi.cs | 300 +++++++++++++++--- .../Api/FakeClassnameTags123Api.cs | 20 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 180 +++++++++-- .../src/Org.OpenAPITools/Api/StoreApi.cs | 80 ++++- .../src/Org.OpenAPITools/Api/UserApi.cs | 160 ++++++++-- .../Client/ExceptionEventArgs.cs | 24 ++ 40 files changed, 2334 insertions(+), 381 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ExceptionEventArgs.mustache create mode 100644 samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java index d52b817990f..68aeb1666fa 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java @@ -1026,6 +1026,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { supportingFiles.add(new SupportingFile("DateTimeJsonConverter.mustache", clientPackageDir, "DateTimeJsonConverter.cs")); supportingFiles.add(new SupportingFile("DateTimeNullableJsonConverter.mustache", clientPackageDir, "DateTimeNullableJsonConverter.cs")); supportingFiles.add(new SupportingFile("ApiResponseEventArgs`1.mustache", clientPackageDir, "ApiResponseEventArgs.cs")); + supportingFiles.add(new SupportingFile("ExceptionEventArgs.mustache", clientPackageDir, "ExceptionEventArgs.cs")); supportingFiles.add(new SupportingFile("JsonSerializerOptionsProvider.mustache", clientPackageDir, "JsonSerializerOptionsProvider.cs")); supportingFiles.add(new SupportingFile("CookieContainer.mustache", clientPackageDir, "CookieContainer.cs")); supportingFiles.add(new SupportingFile("Option.mustache", clientPackageDir, "Option.cs")); diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ExceptionEventArgs.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ExceptionEventArgs.mustache new file mode 100644 index 00000000000..016ef7c697f --- /dev/null +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ExceptionEventArgs.mustache @@ -0,0 +1,24 @@ +using System; + +namespace {{packageName}}.{{clientPackage}} +{ + /// + /// Useful for tracking server health + /// + {{>visibility}} class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OnErrorDefaultImplementation.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OnErrorDefaultImplementation.mustache index bdefb67c6e4..7af8e07602d 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OnErrorDefaultImplementation.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/OnErrorDefaultImplementation.mustache @@ -1 +1,2 @@ - Logger.LogError(exception, "An error occurred while sending the request to the server."); \ No newline at end of file + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index 75676b14a38..f101c1afe1b 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -81,11 +81,21 @@ namespace {{packageName}}.{{apiPackage}} /// public event EventHandler>{{nrt?}} On{{operationId}}; + /// + /// The event raised after an error querying the server + /// + public event EventHandler{{nrt?}} OnError{{operationId}}; + internal void ExecuteOn{{operationId}}(ApiResponse<{{{returnType}}}{{^returnType}}object{{/returnType}}> apiResponse) { On{{operationId}}?.Invoke(this, new ApiResponseEventArgs<{{{returnType}}}{{^returnType}}object{{/returnType}}>(apiResponse)); } + internal void ExecuteOnError{{operationId}}(Exception exception) + { + OnError{{operationId}}?.Invoke(this, new ExceptionEventArgs(exception)); + } + {{/operation}} {{/lambda.trimTrailingWhiteSpace}} } @@ -232,20 +242,22 @@ namespace {{packageName}}.{{apiPackage}} {{/allParams}} private void OnError{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}Exception exception string pathFormat string path {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}) { + bool suppressDefaultLog = false; + OnError{{operationId}}({{#lambda.joinWithComma}}ref suppressDefaultLog exception pathFormat path {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); {{>OnErrorDefaultImplementation}} - OnError{{operationId}}({{#lambda.joinWithComma}}exception pathFormat path {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// {{#allParams}} /// {{/allParams}} - partial void OnError{{operationId}}({{#lambda.joinWithComma}}Exception exception string pathFormat string path {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); + partial void OnError{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLog Exception exception string pathFormat string path {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); /// /// {{summary}} {{notes}} @@ -549,6 +561,7 @@ namespace {{packageName}}.{{apiPackage}} catch(Exception e) { OnError{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}e "{{path}}" uriBuilderLocalVar.Path {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}}); + Events.ExecuteOnError{{operationId}}(e); throw; } {{/lambda.trimLineBreaks}} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES index 60c779c5ced..04ee5f80fe4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES @@ -118,6 +118,7 @@ src/Org.OpenAPITools/Client/ClientUtils.cs src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 81e2eb36092..695312bf4d1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -73,10 +73,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnCall123TestSpecialTags; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorCall123TestSpecialTags; + internal void ExecuteOnCall123TestSpecialTags(ApiResponse apiResponse) { OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception) + { + OnErrorCall123TestSpecialTags?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -191,18 +201,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCall123TestSpecialTags(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorCall123TestSpecialTags(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorCall123TestSpecialTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test special tags To test special tags and operation ID starting with number @@ -291,6 +304,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorCall123TestSpecialTags(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs index 14e463f368d..91831f2632e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -115,30 +115,60 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnFooGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFooGet; + internal void ExecuteOnFooGet(ApiResponse apiResponse) { OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFooGet(Exception exception) + { + OnErrorFooGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnGetCountry; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetCountry; + internal void ExecuteOnGetCountry(ApiResponse apiResponse) { OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetCountry(Exception exception) + { + OnErrorGetCountry?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>>? OnHello; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorHello; + internal void ExecuteOnHello(ApiResponse> apiResponse) { OnHello?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + + internal void ExecuteOnErrorHello(Exception exception) + { + OnErrorHello?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -237,17 +267,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFooGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorFooGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorFooGet(Exception exception, string pathFormat, string path); + partial void OnErrorFooGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// @@ -317,6 +350,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFooGet(e); throw; } } @@ -364,18 +398,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetCountry(exception, pathFormat, path, country); + bool suppressDefaultLog = false; + OnErrorGetCountry(ref suppressDefaultLog, exception, pathFormat, path, country); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country); + partial void OnErrorGetCountry(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string country); /// /// @@ -461,6 +498,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); + Events.ExecuteOnErrorGetCountry(e); throw; } } @@ -492,17 +530,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorHello(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorHello(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorHello(Exception exception, string pathFormat, string path); + partial void OnErrorHello(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Hello Hello @@ -572,6 +613,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorHello(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs index 611c2ce7ff0..4334c856bb0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeApi.cs @@ -463,150 +463,300 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnFakeHealthGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFakeHealthGet; + internal void ExecuteOnFakeHealthGet(ApiResponse apiResponse) { OnFakeHealthGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeHealthGet(Exception exception) + { + OnErrorFakeHealthGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnFakeOuterBooleanSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFakeOuterBooleanSerialize; + internal void ExecuteOnFakeOuterBooleanSerialize(ApiResponse apiResponse) { OnFakeOuterBooleanSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterBooleanSerialize(Exception exception) + { + OnErrorFakeOuterBooleanSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnFakeOuterCompositeSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFakeOuterCompositeSerialize; + internal void ExecuteOnFakeOuterCompositeSerialize(ApiResponse apiResponse) { OnFakeOuterCompositeSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterCompositeSerialize(Exception exception) + { + OnErrorFakeOuterCompositeSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnFakeOuterNumberSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFakeOuterNumberSerialize; + internal void ExecuteOnFakeOuterNumberSerialize(ApiResponse apiResponse) { OnFakeOuterNumberSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterNumberSerialize(Exception exception) + { + OnErrorFakeOuterNumberSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnFakeOuterStringSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFakeOuterStringSerialize; + internal void ExecuteOnFakeOuterStringSerialize(ApiResponse apiResponse) { OnFakeOuterStringSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterStringSerialize(Exception exception) + { + OnErrorFakeOuterStringSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>>? OnGetArrayOfEnums; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetArrayOfEnums; + internal void ExecuteOnGetArrayOfEnums(ApiResponse> apiResponse) { OnGetArrayOfEnums?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) + { + OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestBodyWithFileSchema; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestBodyWithFileSchema; + internal void ExecuteOnTestBodyWithFileSchema(ApiResponse apiResponse) { OnTestBodyWithFileSchema?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestBodyWithFileSchema(Exception exception) + { + OnErrorTestBodyWithFileSchema?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestBodyWithQueryParams; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestBodyWithQueryParams; + internal void ExecuteOnTestBodyWithQueryParams(ApiResponse apiResponse) { OnTestBodyWithQueryParams?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestBodyWithQueryParams(Exception exception) + { + OnErrorTestBodyWithQueryParams?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestClientModel; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestClientModel; + internal void ExecuteOnTestClientModel(ApiResponse apiResponse) { OnTestClientModel?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestClientModel(Exception exception) + { + OnErrorTestClientModel?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestEndpointParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestEndpointParameters; + internal void ExecuteOnTestEndpointParameters(ApiResponse apiResponse) { OnTestEndpointParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestEndpointParameters(Exception exception) + { + OnErrorTestEndpointParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestEnumParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestEnumParameters; + internal void ExecuteOnTestEnumParameters(ApiResponse apiResponse) { OnTestEnumParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestEnumParameters(Exception exception) + { + OnErrorTestEnumParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestGroupParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestGroupParameters; + internal void ExecuteOnTestGroupParameters(ApiResponse apiResponse) { OnTestGroupParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestGroupParameters(Exception exception) + { + OnErrorTestGroupParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestInlineAdditionalProperties; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestInlineAdditionalProperties; + internal void ExecuteOnTestInlineAdditionalProperties(ApiResponse apiResponse) { OnTestInlineAdditionalProperties?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestInlineAdditionalProperties(Exception exception) + { + OnErrorTestInlineAdditionalProperties?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestJsonFormData; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestJsonFormData; + internal void ExecuteOnTestJsonFormData(ApiResponse apiResponse) { OnTestJsonFormData?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestJsonFormData(Exception exception) + { + OnErrorTestJsonFormData?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnTestQueryParameterCollectionFormat; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestQueryParameterCollectionFormat; + internal void ExecuteOnTestQueryParameterCollectionFormat(ApiResponse apiResponse) { OnTestQueryParameterCollectionFormat?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception exception) + { + OnErrorTestQueryParameterCollectionFormat?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -705,17 +855,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeHealthGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorFakeHealthGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path); + partial void OnErrorFakeHealthGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Health check endpoint @@ -785,6 +938,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFakeHealthGet(e); throw; } } @@ -821,18 +975,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterBooleanSerialize(exception, pathFormat, path, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterBooleanSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, Option body); + partial void OnErrorFakeOuterBooleanSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); /// /// Test serialization of outer boolean types @@ -920,6 +1077,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterBooleanSerialize(e); throw; } } @@ -967,18 +1125,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option outerComposite) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterCompositeSerialize(exception, pathFormat, path, outerComposite); + bool suppressDefaultLog = false; + OnErrorFakeOuterCompositeSerialize(ref suppressDefaultLog, exception, pathFormat, path, outerComposite); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, Option outerComposite); + partial void OnErrorFakeOuterCompositeSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option outerComposite); /// /// Test serialization of object with outer number type @@ -1068,6 +1229,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + Events.ExecuteOnErrorFakeOuterCompositeSerialize(e); throw; } } @@ -1104,18 +1266,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterNumberSerialize(exception, pathFormat, path, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterNumberSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, Option body); + partial void OnErrorFakeOuterNumberSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); /// /// Test serialization of outer number types @@ -1203,6 +1368,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterNumberSerialize(e); throw; } } @@ -1253,19 +1419,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterStringSerialize(exception, pathFormat, path, requiredStringUuid, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterStringSerialize(ref suppressDefaultLog, exception, pathFormat, path, requiredStringUuid, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); + partial void OnErrorFakeOuterStringSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); /// /// Test serialization of outer string types @@ -1363,6 +1532,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + Events.ExecuteOnErrorFakeOuterStringSerialize(e); throw; } } @@ -1394,17 +1564,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetArrayOfEnums(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorGetArrayOfEnums(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path); + partial void OnErrorGetArrayOfEnums(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Array of Enums @@ -1474,6 +1647,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetArrayOfEnums(e); throw; } } @@ -1521,18 +1695,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestBodyWithFileSchema(exception, pathFormat, path, fileSchemaTestClass); + bool suppressDefaultLog = false; + OnErrorTestBodyWithFileSchema(ref suppressDefaultLog, exception, pathFormat, path, fileSchemaTestClass); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + partial void OnErrorTestBodyWithFileSchema(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); /// /// For this test, the body for this request much reference a schema named `File`. @@ -1612,6 +1789,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + Events.ExecuteOnErrorTestBodyWithFileSchema(e); throw; } } @@ -1666,19 +1844,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestBodyWithQueryParams(exception, pathFormat, path, user, query); + bool suppressDefaultLog = false; + OnErrorTestBodyWithQueryParams(ref suppressDefaultLog, exception, pathFormat, path, user, query); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query); + partial void OnErrorTestBodyWithQueryParams(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string query); /// /// @@ -1766,6 +1947,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + Events.ExecuteOnErrorTestBodyWithQueryParams(e); throw; } } @@ -1813,18 +1995,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestClientModel(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorTestClientModel(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorTestClientModel(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test \"client\" model To test \"client\" model @@ -1913,6 +2098,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClientModel(e); throw; } } @@ -2019,13 +2205,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestEndpointParameters(exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + bool suppressDefaultLog = false; + OnErrorTestEndpointParameters(ref suppressDefaultLog, exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2043,7 +2232,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -2203,6 +2392,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + Events.ExecuteOnErrorTestEndpointParameters(e); throw; } } @@ -2291,13 +2481,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestEnumParameters(exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + bool suppressDefaultLog = false; + OnErrorTestEnumParameters(ref suppressDefaultLog, exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2309,7 +2502,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); + partial void OnErrorTestEnumParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); /// /// To test enum parameters To test enum parameters @@ -2433,6 +2626,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + Events.ExecuteOnErrorTestEnumParameters(e); throw; } } @@ -2484,13 +2678,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestGroupParameters(exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + bool suppressDefaultLog = false; + OnErrorTestGroupParameters(ref suppressDefaultLog, exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2500,7 +2697,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); + partial void OnErrorTestGroupParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); /// /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) @@ -2605,6 +2802,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + Events.ExecuteOnErrorTestGroupParameters(e); throw; } } @@ -2652,18 +2850,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestInlineAdditionalProperties(exception, pathFormat, path, requestBody); + bool suppressDefaultLog = false; + OnErrorTestInlineAdditionalProperties(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody); + partial void OnErrorTestInlineAdditionalProperties(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); /// /// test inline additionalProperties @@ -2743,6 +2944,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestInlineAdditionalProperties(e); throw; } } @@ -2797,19 +2999,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestJsonFormData(exception, pathFormat, path, param, param2); + bool suppressDefaultLog = false; + OnErrorTestJsonFormData(ref suppressDefaultLog, exception, pathFormat, path, param, param2); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2); + partial void OnErrorTestJsonFormData(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string param, string param2); /// /// test json serialization of form data @@ -2899,6 +3104,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + Events.ExecuteOnErrorTestJsonFormData(e); throw; } } @@ -2994,13 +3200,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string? requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestQueryParameterCollectionFormat(exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + bool suppressDefaultLog = false; + OnErrorTestQueryParameterCollectionFormat(ref suppressDefaultLog, exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -3013,7 +3222,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string? requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); + partial void OnErrorTestQueryParameterCollectionFormat(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string? requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); /// /// To test the collection format in query parameters @@ -3114,6 +3323,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + Events.ExecuteOnErrorTestQueryParameterCollectionFormat(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index ef613a6fb5a..8ce783a3320 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -73,10 +73,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnTestClassname; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorTestClassname; + internal void ExecuteOnTestClassname(ApiResponse apiResponse) { OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorTestClassname(Exception exception) + { + OnErrorTestClassname?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -191,18 +201,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestClassname(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorTestClassname(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorTestClassname(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test class name in snake case To test class name in snake case @@ -306,6 +319,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClassname(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs index f9df2618276..ad0b273a169 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/PetApi.cs @@ -271,90 +271,180 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnAddPet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorAddPet; + internal void ExecuteOnAddPet(ApiResponse apiResponse) { OnAddPet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorAddPet(Exception exception) + { + OnErrorAddPet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnDeletePet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorDeletePet; + internal void ExecuteOnDeletePet(ApiResponse apiResponse) { OnDeletePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeletePet(Exception exception) + { + OnErrorDeletePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>>? OnFindPetsByStatus; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFindPetsByStatus; + internal void ExecuteOnFindPetsByStatus(ApiResponse> apiResponse) { OnFindPetsByStatus?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorFindPetsByStatus(Exception exception) + { + OnErrorFindPetsByStatus?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>>? OnFindPetsByTags; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorFindPetsByTags; + internal void ExecuteOnFindPetsByTags(ApiResponse> apiResponse) { OnFindPetsByTags?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorFindPetsByTags(Exception exception) + { + OnErrorFindPetsByTags?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnGetPetById; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetPetById; + internal void ExecuteOnGetPetById(ApiResponse apiResponse) { OnGetPetById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetPetById(Exception exception) + { + OnErrorGetPetById?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnUpdatePet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUpdatePet; + internal void ExecuteOnUpdatePet(ApiResponse apiResponse) { OnUpdatePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUpdatePet(Exception exception) + { + OnErrorUpdatePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnUpdatePetWithForm; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUpdatePetWithForm; + internal void ExecuteOnUpdatePetWithForm(ApiResponse apiResponse) { OnUpdatePetWithForm?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUpdatePetWithForm(Exception exception) + { + OnErrorUpdatePetWithForm?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnUploadFile; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFile; + internal void ExecuteOnUploadFile(ApiResponse apiResponse) { OnUploadFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUploadFile(Exception exception) + { + OnErrorUploadFile?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnUploadFileWithRequiredFile; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUploadFileWithRequiredFile; + internal void ExecuteOnUploadFileWithRequiredFile(ApiResponse apiResponse) { OnUploadFileWithRequiredFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) + { + OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -469,18 +559,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorAddPet(exception, pathFormat, path, pet); + bool suppressDefaultLog = false; + OnErrorAddPet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet); + partial void OnErrorAddPet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); /// /// Add a new pet to the store @@ -587,6 +680,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorAddPet(e); throw; } } @@ -637,19 +731,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option apiKey) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeletePet(exception, pathFormat, path, petId, apiKey); + bool suppressDefaultLog = false; + OnErrorDeletePet(ref suppressDefaultLog, exception, pathFormat, path, petId, apiKey); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, Option apiKey); + partial void OnErrorDeletePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option apiKey); /// /// Deletes a pet @@ -734,6 +831,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + Events.ExecuteOnErrorDeletePet(e); throw; } } @@ -781,18 +879,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFindPetsByStatus(exception, pathFormat, path, status); + bool suppressDefaultLog = false; + OnErrorFindPetsByStatus(ref suppressDefaultLog, exception, pathFormat, path, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status); + partial void OnErrorFindPetsByStatus(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List status); /// /// Finds Pets by status Multiple status values can be provided with comma separated strings @@ -901,6 +1002,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + Events.ExecuteOnErrorFindPetsByStatus(e); throw; } } @@ -948,18 +1050,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFindPetsByTags(exception, pathFormat, path, tags); + bool suppressDefaultLog = false; + OnErrorFindPetsByTags(ref suppressDefaultLog, exception, pathFormat, path, tags); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags); + partial void OnErrorFindPetsByTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List tags); /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -1068,6 +1173,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + Events.ExecuteOnErrorFindPetsByTags(e); throw; } } @@ -1104,18 +1210,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetPetById(exception, pathFormat, path, petId); + bool suppressDefaultLog = false; + OnErrorGetPetById(ref suppressDefaultLog, exception, pathFormat, path, petId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId); + partial void OnErrorGetPetById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId); /// /// Find pet by ID Returns a single pet @@ -1203,6 +1312,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + Events.ExecuteOnErrorGetPetById(e); throw; } } @@ -1250,18 +1360,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdatePet(exception, pathFormat, path, pet); + bool suppressDefaultLog = false; + OnErrorUpdatePet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet); + partial void OnErrorUpdatePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); /// /// Update an existing pet @@ -1368,6 +1481,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorUpdatePet(e); throw; } } @@ -1425,20 +1539,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option name, Option status) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdatePetWithForm(exception, pathFormat, path, petId, name, status); + bool suppressDefaultLog = false; + OnErrorUpdatePetWithForm(ref suppressDefaultLog, exception, pathFormat, path, petId, name, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, Option name, Option status); + partial void OnErrorUpdatePetWithForm(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option name, Option status); /// /// Updates a pet in the store with form data @@ -1543,6 +1660,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + Events.ExecuteOnErrorUpdatePetWithForm(e); throw; } } @@ -1600,20 +1718,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUploadFile(exception, pathFormat, path, petId, file, additionalMetadata); + bool suppressDefaultLog = false; + OnErrorUploadFile(ref suppressDefaultLog, exception, pathFormat, path, petId, file, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); + partial void OnErrorUploadFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); /// /// uploads an image @@ -1727,6 +1848,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + Events.ExecuteOnErrorUploadFile(e); throw; } } @@ -1784,20 +1906,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUploadFileWithRequiredFile(exception, pathFormat, path, requiredFile, petId, additionalMetadata); + bool suppressDefaultLog = false; + OnErrorUploadFileWithRequiredFile(ref suppressDefaultLog, exception, pathFormat, path, requiredFile, petId, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); /// /// uploads an image (required) @@ -1911,6 +2036,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + Events.ExecuteOnErrorUploadFileWithRequiredFile(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs index 45063e299cf..81c5c0f713d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/StoreApi.cs @@ -140,40 +140,80 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnDeleteOrder; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorDeleteOrder; + internal void ExecuteOnDeleteOrder(ApiResponse apiResponse) { OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeleteOrder(Exception exception) + { + OnErrorDeleteOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>>? OnGetInventory; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetInventory; + internal void ExecuteOnGetInventory(ApiResponse> apiResponse) { OnGetInventory?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorGetInventory(Exception exception) + { + OnErrorGetInventory?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnGetOrderById; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetOrderById; + internal void ExecuteOnGetOrderById(ApiResponse apiResponse) { OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetOrderById(Exception exception) + { + OnErrorGetOrderById?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnPlaceOrder; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorPlaceOrder; + internal void ExecuteOnPlaceOrder(ApiResponse apiResponse) { OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorPlaceOrder(Exception exception) + { + OnErrorPlaceOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -288,18 +328,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeleteOrder(exception, pathFormat, path, orderId); + bool suppressDefaultLog = false; + OnErrorDeleteOrder(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId); + partial void OnErrorDeleteOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string orderId); /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -367,6 +410,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorDeleteOrder(e); throw; } } @@ -398,17 +442,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetInventory(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorGetInventory(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorGetInventory(Exception exception, string pathFormat, string path); + partial void OnErrorGetInventory(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Returns pet inventories by status Returns a map of status codes to quantities @@ -490,6 +537,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetInventory(e); throw; } } @@ -526,18 +574,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetOrderById(exception, pathFormat, path, orderId); + bool suppressDefaultLog = false; + OnErrorGetOrderById(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId); + partial void OnErrorGetOrderById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long orderId); /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions @@ -613,6 +664,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorGetOrderById(e); throw; } } @@ -660,18 +712,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorPlaceOrder(exception, pathFormat, path, order); + bool suppressDefaultLog = false; + OnErrorPlaceOrder(ref suppressDefaultLog, exception, pathFormat, path, order); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order); + partial void OnErrorPlaceOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Order order); /// /// Place an order for a pet @@ -761,6 +816,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); + Events.ExecuteOnErrorPlaceOrder(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs index ccb4e92923e..7df84d485d0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/UserApi.cs @@ -236,80 +236,160 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnCreateUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorCreateUser; + internal void ExecuteOnCreateUser(ApiResponse apiResponse) { OnCreateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUser(Exception exception) + { + OnErrorCreateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnCreateUsersWithArrayInput; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorCreateUsersWithArrayInput; + internal void ExecuteOnCreateUsersWithArrayInput(ApiResponse apiResponse) { OnCreateUsersWithArrayInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUsersWithArrayInput(Exception exception) + { + OnErrorCreateUsersWithArrayInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnCreateUsersWithListInput; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorCreateUsersWithListInput; + internal void ExecuteOnCreateUsersWithListInput(ApiResponse apiResponse) { OnCreateUsersWithListInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUsersWithListInput(Exception exception) + { + OnErrorCreateUsersWithListInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnDeleteUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorDeleteUser; + internal void ExecuteOnDeleteUser(ApiResponse apiResponse) { OnDeleteUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeleteUser(Exception exception) + { + OnErrorDeleteUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnGetUserByName; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetUserByName; + internal void ExecuteOnGetUserByName(ApiResponse apiResponse) { OnGetUserByName?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetUserByName(Exception exception) + { + OnErrorGetUserByName?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnLoginUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorLoginUser; + internal void ExecuteOnLoginUser(ApiResponse apiResponse) { OnLoginUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorLoginUser(Exception exception) + { + OnErrorLoginUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnLogoutUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorLogoutUser; + internal void ExecuteOnLogoutUser(ApiResponse apiResponse) { OnLogoutUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorLogoutUser(Exception exception) + { + OnErrorLogoutUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>? OnUpdateUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorUpdateUser; + internal void ExecuteOnUpdateUser(ApiResponse apiResponse) { OnUpdateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorUpdateUser(Exception exception) + { + OnErrorUpdateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -424,18 +504,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUser(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUser(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user); + partial void OnErrorCreateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user); /// /// Create user This can only be done by the logged in user. @@ -515,6 +598,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUser(e); throw; } } @@ -562,18 +646,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUsersWithArrayInput(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUsersWithArrayInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user); + partial void OnErrorCreateUsersWithArrayInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); /// /// Creates list of users with given input array @@ -653,6 +740,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithArrayInput(e); throw; } } @@ -700,18 +788,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUsersWithListInput(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUsersWithListInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user); + partial void OnErrorCreateUsersWithListInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); /// /// Creates list of users with given input array @@ -791,6 +882,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithListInput(e); throw; } } @@ -838,18 +930,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeleteUser(exception, pathFormat, path, username); + bool suppressDefaultLog = false; + OnErrorDeleteUser(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username); + partial void OnErrorDeleteUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); /// /// Delete user This can only be done by the logged in user. @@ -917,6 +1012,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorDeleteUser(e); throw; } } @@ -964,18 +1060,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetUserByName(exception, pathFormat, path, username); + bool suppressDefaultLog = false; + OnErrorGetUserByName(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username); + partial void OnErrorGetUserByName(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); /// /// Get user by user name @@ -1053,6 +1152,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorGetUserByName(e); throw; } } @@ -1107,19 +1207,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorLoginUser(exception, pathFormat, path, username, password); + bool suppressDefaultLog = false; + OnErrorLoginUser(ref suppressDefaultLog, exception, pathFormat, path, username, password); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password); + partial void OnErrorLoginUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username, string password); /// /// Logs user into the system @@ -1205,6 +1308,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); + Events.ExecuteOnErrorLoginUser(e); throw; } } @@ -1236,17 +1340,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorLogoutUser(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorLogoutUser(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorLogoutUser(Exception exception, string pathFormat, string path); + partial void OnErrorLogoutUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Logs out current logged in user session @@ -1307,6 +1414,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorLogoutUser(e); throw; } } @@ -1361,19 +1469,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdateUser(exception, pathFormat, path, user, username); + bool suppressDefaultLog = false; + OnErrorUpdateUser(ref suppressDefaultLog, exception, pathFormat, path, user, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username); + partial void OnErrorUpdateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string username); /// /// Updated user This can only be done by the logged in user. @@ -1456,6 +1567,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + Events.ExecuteOnErrorUpdateUser(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 00000000000..dcfab667823 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES index 60c779c5ced..04ee5f80fe4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES @@ -118,6 +118,7 @@ src/Org.OpenAPITools/Client/ClientUtils.cs src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 16832f5d624..29644b3f55a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -71,10 +71,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnCall123TestSpecialTags; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCall123TestSpecialTags; + internal void ExecuteOnCall123TestSpecialTags(ApiResponse apiResponse) { OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception) + { + OnErrorCall123TestSpecialTags?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -189,18 +199,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCall123TestSpecialTags(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorCall123TestSpecialTags(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorCall123TestSpecialTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test special tags To test special tags and operation ID starting with number @@ -289,6 +302,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorCall123TestSpecialTags(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs index bb3768fcefb..6be47a6f318 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -113,30 +113,60 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnFooGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFooGet; + internal void ExecuteOnFooGet(ApiResponse apiResponse) { OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFooGet(Exception exception) + { + OnErrorFooGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetCountry; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetCountry; + internal void ExecuteOnGetCountry(ApiResponse apiResponse) { OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetCountry(Exception exception) + { + OnErrorGetCountry?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnHello; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorHello; + internal void ExecuteOnHello(ApiResponse> apiResponse) { OnHello?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + + internal void ExecuteOnErrorHello(Exception exception) + { + OnErrorHello?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -235,17 +265,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFooGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorFooGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorFooGet(Exception exception, string pathFormat, string path); + partial void OnErrorFooGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// @@ -315,6 +348,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFooGet(e); throw; } } @@ -362,18 +396,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetCountry(exception, pathFormat, path, country); + bool suppressDefaultLog = false; + OnErrorGetCountry(ref suppressDefaultLog, exception, pathFormat, path, country); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country); + partial void OnErrorGetCountry(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string country); /// /// @@ -459,6 +496,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); + Events.ExecuteOnErrorGetCountry(e); throw; } } @@ -490,17 +528,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorHello(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorHello(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorHello(Exception exception, string pathFormat, string path); + partial void OnErrorHello(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Hello Hello @@ -570,6 +611,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorHello(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs index 41d0619526c..b91da3ec838 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeApi.cs @@ -461,150 +461,300 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnFakeHealthGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeHealthGet; + internal void ExecuteOnFakeHealthGet(ApiResponse apiResponse) { OnFakeHealthGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeHealthGet(Exception exception) + { + OnErrorFakeHealthGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterBooleanSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterBooleanSerialize; + internal void ExecuteOnFakeOuterBooleanSerialize(ApiResponse apiResponse) { OnFakeOuterBooleanSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterBooleanSerialize(Exception exception) + { + OnErrorFakeOuterBooleanSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterCompositeSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterCompositeSerialize; + internal void ExecuteOnFakeOuterCompositeSerialize(ApiResponse apiResponse) { OnFakeOuterCompositeSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterCompositeSerialize(Exception exception) + { + OnErrorFakeOuterCompositeSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterNumberSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterNumberSerialize; + internal void ExecuteOnFakeOuterNumberSerialize(ApiResponse apiResponse) { OnFakeOuterNumberSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterNumberSerialize(Exception exception) + { + OnErrorFakeOuterNumberSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterStringSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterStringSerialize; + internal void ExecuteOnFakeOuterStringSerialize(ApiResponse apiResponse) { OnFakeOuterStringSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterStringSerialize(Exception exception) + { + OnErrorFakeOuterStringSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnGetArrayOfEnums; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetArrayOfEnums; + internal void ExecuteOnGetArrayOfEnums(ApiResponse> apiResponse) { OnGetArrayOfEnums?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) + { + OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestBodyWithFileSchema; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithFileSchema; + internal void ExecuteOnTestBodyWithFileSchema(ApiResponse apiResponse) { OnTestBodyWithFileSchema?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestBodyWithFileSchema(Exception exception) + { + OnErrorTestBodyWithFileSchema?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestBodyWithQueryParams; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithQueryParams; + internal void ExecuteOnTestBodyWithQueryParams(ApiResponse apiResponse) { OnTestBodyWithQueryParams?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestBodyWithQueryParams(Exception exception) + { + OnErrorTestBodyWithQueryParams?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestClientModel; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClientModel; + internal void ExecuteOnTestClientModel(ApiResponse apiResponse) { OnTestClientModel?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestClientModel(Exception exception) + { + OnErrorTestClientModel?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestEndpointParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEndpointParameters; + internal void ExecuteOnTestEndpointParameters(ApiResponse apiResponse) { OnTestEndpointParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestEndpointParameters(Exception exception) + { + OnErrorTestEndpointParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestEnumParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEnumParameters; + internal void ExecuteOnTestEnumParameters(ApiResponse apiResponse) { OnTestEnumParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestEnumParameters(Exception exception) + { + OnErrorTestEnumParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestGroupParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestGroupParameters; + internal void ExecuteOnTestGroupParameters(ApiResponse apiResponse) { OnTestGroupParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestGroupParameters(Exception exception) + { + OnErrorTestGroupParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestInlineAdditionalProperties; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestInlineAdditionalProperties; + internal void ExecuteOnTestInlineAdditionalProperties(ApiResponse apiResponse) { OnTestInlineAdditionalProperties?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestInlineAdditionalProperties(Exception exception) + { + OnErrorTestInlineAdditionalProperties?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestJsonFormData; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestJsonFormData; + internal void ExecuteOnTestJsonFormData(ApiResponse apiResponse) { OnTestJsonFormData?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestJsonFormData(Exception exception) + { + OnErrorTestJsonFormData?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestQueryParameterCollectionFormat; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestQueryParameterCollectionFormat; + internal void ExecuteOnTestQueryParameterCollectionFormat(ApiResponse apiResponse) { OnTestQueryParameterCollectionFormat?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception exception) + { + OnErrorTestQueryParameterCollectionFormat?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -703,17 +853,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeHealthGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorFakeHealthGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path); + partial void OnErrorFakeHealthGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Health check endpoint @@ -783,6 +936,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFakeHealthGet(e); throw; } } @@ -819,18 +973,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterBooleanSerialize(exception, pathFormat, path, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterBooleanSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, Option body); + partial void OnErrorFakeOuterBooleanSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); /// /// Test serialization of outer boolean types @@ -918,6 +1075,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterBooleanSerialize(e); throw; } } @@ -965,18 +1123,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option outerComposite) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterCompositeSerialize(exception, pathFormat, path, outerComposite); + bool suppressDefaultLog = false; + OnErrorFakeOuterCompositeSerialize(ref suppressDefaultLog, exception, pathFormat, path, outerComposite); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, Option outerComposite); + partial void OnErrorFakeOuterCompositeSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option outerComposite); /// /// Test serialization of object with outer number type @@ -1066,6 +1227,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + Events.ExecuteOnErrorFakeOuterCompositeSerialize(e); throw; } } @@ -1102,18 +1264,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterNumberSerialize(exception, pathFormat, path, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterNumberSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, Option body); + partial void OnErrorFakeOuterNumberSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); /// /// Test serialization of outer number types @@ -1201,6 +1366,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterNumberSerialize(e); throw; } } @@ -1251,19 +1417,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterStringSerialize(exception, pathFormat, path, requiredStringUuid, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterStringSerialize(ref suppressDefaultLog, exception, pathFormat, path, requiredStringUuid, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); + partial void OnErrorFakeOuterStringSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); /// /// Test serialization of outer string types @@ -1361,6 +1530,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + Events.ExecuteOnErrorFakeOuterStringSerialize(e); throw; } } @@ -1392,17 +1562,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetArrayOfEnums(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorGetArrayOfEnums(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path); + partial void OnErrorGetArrayOfEnums(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Array of Enums @@ -1472,6 +1645,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetArrayOfEnums(e); throw; } } @@ -1519,18 +1693,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestBodyWithFileSchema(exception, pathFormat, path, fileSchemaTestClass); + bool suppressDefaultLog = false; + OnErrorTestBodyWithFileSchema(ref suppressDefaultLog, exception, pathFormat, path, fileSchemaTestClass); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + partial void OnErrorTestBodyWithFileSchema(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); /// /// For this test, the body for this request much reference a schema named `File`. @@ -1610,6 +1787,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + Events.ExecuteOnErrorTestBodyWithFileSchema(e); throw; } } @@ -1664,19 +1842,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestBodyWithQueryParams(exception, pathFormat, path, user, query); + bool suppressDefaultLog = false; + OnErrorTestBodyWithQueryParams(ref suppressDefaultLog, exception, pathFormat, path, user, query); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query); + partial void OnErrorTestBodyWithQueryParams(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string query); /// /// @@ -1764,6 +1945,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + Events.ExecuteOnErrorTestBodyWithQueryParams(e); throw; } } @@ -1811,18 +1993,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestClientModel(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorTestClientModel(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorTestClientModel(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test \"client\" model To test \"client\" model @@ -1911,6 +2096,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClientModel(e); throw; } } @@ -2017,13 +2203,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestEndpointParameters(exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + bool suppressDefaultLog = false; + OnErrorTestEndpointParameters(ref suppressDefaultLog, exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2041,7 +2230,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -2201,6 +2390,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + Events.ExecuteOnErrorTestEndpointParameters(e); throw; } } @@ -2289,13 +2479,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestEnumParameters(exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + bool suppressDefaultLog = false; + OnErrorTestEnumParameters(ref suppressDefaultLog, exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2307,7 +2500,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); + partial void OnErrorTestEnumParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); /// /// To test enum parameters To test enum parameters @@ -2431,6 +2624,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + Events.ExecuteOnErrorTestEnumParameters(e); throw; } } @@ -2482,13 +2676,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestGroupParameters(exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + bool suppressDefaultLog = false; + OnErrorTestGroupParameters(ref suppressDefaultLog, exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2498,7 +2695,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); + partial void OnErrorTestGroupParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); /// /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) @@ -2603,6 +2800,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + Events.ExecuteOnErrorTestGroupParameters(e); throw; } } @@ -2650,18 +2848,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestInlineAdditionalProperties(exception, pathFormat, path, requestBody); + bool suppressDefaultLog = false; + OnErrorTestInlineAdditionalProperties(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody); + partial void OnErrorTestInlineAdditionalProperties(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); /// /// test inline additionalProperties @@ -2741,6 +2942,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestInlineAdditionalProperties(e); throw; } } @@ -2795,19 +2997,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestJsonFormData(exception, pathFormat, path, param, param2); + bool suppressDefaultLog = false; + OnErrorTestJsonFormData(ref suppressDefaultLog, exception, pathFormat, path, param, param2); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2); + partial void OnErrorTestJsonFormData(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string param, string param2); /// /// test json serialization of form data @@ -2897,6 +3102,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + Events.ExecuteOnErrorTestJsonFormData(e); throw; } } @@ -2992,13 +3198,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestQueryParameterCollectionFormat(exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + bool suppressDefaultLog = false; + OnErrorTestQueryParameterCollectionFormat(ref suppressDefaultLog, exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -3011,7 +3220,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); + partial void OnErrorTestQueryParameterCollectionFormat(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); /// /// To test the collection format in query parameters @@ -3112,6 +3321,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + Events.ExecuteOnErrorTestQueryParameterCollectionFormat(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index c1cca9d96be..28833de3175 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -71,10 +71,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnTestClassname; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClassname; + internal void ExecuteOnTestClassname(ApiResponse apiResponse) { OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorTestClassname(Exception exception) + { + OnErrorTestClassname?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -189,18 +199,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestClassname(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorTestClassname(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorTestClassname(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test class name in snake case To test class name in snake case @@ -304,6 +317,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClassname(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs index 83bf38174fd..8217daa081c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/PetApi.cs @@ -269,90 +269,180 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnAddPet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorAddPet; + internal void ExecuteOnAddPet(ApiResponse apiResponse) { OnAddPet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorAddPet(Exception exception) + { + OnErrorAddPet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnDeletePet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeletePet; + internal void ExecuteOnDeletePet(ApiResponse apiResponse) { OnDeletePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeletePet(Exception exception) + { + OnErrorDeletePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnFindPetsByStatus; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByStatus; + internal void ExecuteOnFindPetsByStatus(ApiResponse> apiResponse) { OnFindPetsByStatus?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorFindPetsByStatus(Exception exception) + { + OnErrorFindPetsByStatus?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnFindPetsByTags; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByTags; + internal void ExecuteOnFindPetsByTags(ApiResponse> apiResponse) { OnFindPetsByTags?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorFindPetsByTags(Exception exception) + { + OnErrorFindPetsByTags?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetPetById; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetPetById; + internal void ExecuteOnGetPetById(ApiResponse apiResponse) { OnGetPetById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetPetById(Exception exception) + { + OnErrorGetPetById?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUpdatePet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePet; + internal void ExecuteOnUpdatePet(ApiResponse apiResponse) { OnUpdatePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUpdatePet(Exception exception) + { + OnErrorUpdatePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUpdatePetWithForm; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePetWithForm; + internal void ExecuteOnUpdatePetWithForm(ApiResponse apiResponse) { OnUpdatePetWithForm?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUpdatePetWithForm(Exception exception) + { + OnErrorUpdatePetWithForm?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUploadFile; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFile; + internal void ExecuteOnUploadFile(ApiResponse apiResponse) { OnUploadFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUploadFile(Exception exception) + { + OnErrorUploadFile?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUploadFileWithRequiredFile; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFileWithRequiredFile; + internal void ExecuteOnUploadFileWithRequiredFile(ApiResponse apiResponse) { OnUploadFileWithRequiredFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) + { + OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -467,18 +557,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorAddPet(exception, pathFormat, path, pet); + bool suppressDefaultLog = false; + OnErrorAddPet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet); + partial void OnErrorAddPet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); /// /// Add a new pet to the store @@ -585,6 +678,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorAddPet(e); throw; } } @@ -635,19 +729,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option apiKey) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeletePet(exception, pathFormat, path, petId, apiKey); + bool suppressDefaultLog = false; + OnErrorDeletePet(ref suppressDefaultLog, exception, pathFormat, path, petId, apiKey); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, Option apiKey); + partial void OnErrorDeletePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option apiKey); /// /// Deletes a pet @@ -732,6 +829,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + Events.ExecuteOnErrorDeletePet(e); throw; } } @@ -779,18 +877,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFindPetsByStatus(exception, pathFormat, path, status); + bool suppressDefaultLog = false; + OnErrorFindPetsByStatus(ref suppressDefaultLog, exception, pathFormat, path, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status); + partial void OnErrorFindPetsByStatus(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List status); /// /// Finds Pets by status Multiple status values can be provided with comma separated strings @@ -899,6 +1000,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + Events.ExecuteOnErrorFindPetsByStatus(e); throw; } } @@ -946,18 +1048,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFindPetsByTags(exception, pathFormat, path, tags); + bool suppressDefaultLog = false; + OnErrorFindPetsByTags(ref suppressDefaultLog, exception, pathFormat, path, tags); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags); + partial void OnErrorFindPetsByTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List tags); /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -1066,6 +1171,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + Events.ExecuteOnErrorFindPetsByTags(e); throw; } } @@ -1102,18 +1208,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetPetById(exception, pathFormat, path, petId); + bool suppressDefaultLog = false; + OnErrorGetPetById(ref suppressDefaultLog, exception, pathFormat, path, petId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId); + partial void OnErrorGetPetById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId); /// /// Find pet by ID Returns a single pet @@ -1201,6 +1310,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + Events.ExecuteOnErrorGetPetById(e); throw; } } @@ -1248,18 +1358,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdatePet(exception, pathFormat, path, pet); + bool suppressDefaultLog = false; + OnErrorUpdatePet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet); + partial void OnErrorUpdatePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); /// /// Update an existing pet @@ -1366,6 +1479,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorUpdatePet(e); throw; } } @@ -1423,20 +1537,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option name, Option status) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdatePetWithForm(exception, pathFormat, path, petId, name, status); + bool suppressDefaultLog = false; + OnErrorUpdatePetWithForm(ref suppressDefaultLog, exception, pathFormat, path, petId, name, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, Option name, Option status); + partial void OnErrorUpdatePetWithForm(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option name, Option status); /// /// Updates a pet in the store with form data @@ -1541,6 +1658,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + Events.ExecuteOnErrorUpdatePetWithForm(e); throw; } } @@ -1598,20 +1716,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUploadFile(exception, pathFormat, path, petId, file, additionalMetadata); + bool suppressDefaultLog = false; + OnErrorUploadFile(ref suppressDefaultLog, exception, pathFormat, path, petId, file, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); + partial void OnErrorUploadFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); /// /// uploads an image @@ -1725,6 +1846,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + Events.ExecuteOnErrorUploadFile(e); throw; } } @@ -1782,20 +1904,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUploadFileWithRequiredFile(exception, pathFormat, path, requiredFile, petId, additionalMetadata); + bool suppressDefaultLog = false; + OnErrorUploadFileWithRequiredFile(ref suppressDefaultLog, exception, pathFormat, path, requiredFile, petId, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); /// /// uploads an image (required) @@ -1909,6 +2034,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + Events.ExecuteOnErrorUploadFileWithRequiredFile(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs index c80edd61c5d..e4b4f0b5b8e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/StoreApi.cs @@ -138,40 +138,80 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnDeleteOrder; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteOrder; + internal void ExecuteOnDeleteOrder(ApiResponse apiResponse) { OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeleteOrder(Exception exception) + { + OnErrorDeleteOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnGetInventory; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetInventory; + internal void ExecuteOnGetInventory(ApiResponse> apiResponse) { OnGetInventory?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorGetInventory(Exception exception) + { + OnErrorGetInventory?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetOrderById; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetOrderById; + internal void ExecuteOnGetOrderById(ApiResponse apiResponse) { OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetOrderById(Exception exception) + { + OnErrorGetOrderById?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnPlaceOrder; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorPlaceOrder; + internal void ExecuteOnPlaceOrder(ApiResponse apiResponse) { OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorPlaceOrder(Exception exception) + { + OnErrorPlaceOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -286,18 +326,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeleteOrder(exception, pathFormat, path, orderId); + bool suppressDefaultLog = false; + OnErrorDeleteOrder(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId); + partial void OnErrorDeleteOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string orderId); /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -365,6 +408,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorDeleteOrder(e); throw; } } @@ -396,17 +440,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetInventory(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorGetInventory(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorGetInventory(Exception exception, string pathFormat, string path); + partial void OnErrorGetInventory(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Returns pet inventories by status Returns a map of status codes to quantities @@ -488,6 +535,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetInventory(e); throw; } } @@ -524,18 +572,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetOrderById(exception, pathFormat, path, orderId); + bool suppressDefaultLog = false; + OnErrorGetOrderById(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId); + partial void OnErrorGetOrderById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long orderId); /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions @@ -611,6 +662,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorGetOrderById(e); throw; } } @@ -658,18 +710,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorPlaceOrder(exception, pathFormat, path, order); + bool suppressDefaultLog = false; + OnErrorPlaceOrder(ref suppressDefaultLog, exception, pathFormat, path, order); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order); + partial void OnErrorPlaceOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Order order); /// /// Place an order for a pet @@ -759,6 +814,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); + Events.ExecuteOnErrorPlaceOrder(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs index 64bc74c48bd..06eb3bbf706 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/UserApi.cs @@ -234,80 +234,160 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnCreateUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUser; + internal void ExecuteOnCreateUser(ApiResponse apiResponse) { OnCreateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUser(Exception exception) + { + OnErrorCreateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnCreateUsersWithArrayInput; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithArrayInput; + internal void ExecuteOnCreateUsersWithArrayInput(ApiResponse apiResponse) { OnCreateUsersWithArrayInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUsersWithArrayInput(Exception exception) + { + OnErrorCreateUsersWithArrayInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnCreateUsersWithListInput; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithListInput; + internal void ExecuteOnCreateUsersWithListInput(ApiResponse apiResponse) { OnCreateUsersWithListInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUsersWithListInput(Exception exception) + { + OnErrorCreateUsersWithListInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnDeleteUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteUser; + internal void ExecuteOnDeleteUser(ApiResponse apiResponse) { OnDeleteUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeleteUser(Exception exception) + { + OnErrorDeleteUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetUserByName; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetUserByName; + internal void ExecuteOnGetUserByName(ApiResponse apiResponse) { OnGetUserByName?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetUserByName(Exception exception) + { + OnErrorGetUserByName?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnLoginUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLoginUser; + internal void ExecuteOnLoginUser(ApiResponse apiResponse) { OnLoginUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorLoginUser(Exception exception) + { + OnErrorLoginUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnLogoutUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLogoutUser; + internal void ExecuteOnLogoutUser(ApiResponse apiResponse) { OnLogoutUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorLogoutUser(Exception exception) + { + OnErrorLogoutUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUpdateUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdateUser; + internal void ExecuteOnUpdateUser(ApiResponse apiResponse) { OnUpdateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorUpdateUser(Exception exception) + { + OnErrorUpdateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -422,18 +502,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUser(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUser(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user); + partial void OnErrorCreateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user); /// /// Create user This can only be done by the logged in user. @@ -513,6 +596,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUser(e); throw; } } @@ -560,18 +644,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUsersWithArrayInput(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUsersWithArrayInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user); + partial void OnErrorCreateUsersWithArrayInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); /// /// Creates list of users with given input array @@ -651,6 +738,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithArrayInput(e); throw; } } @@ -698,18 +786,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUsersWithListInput(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUsersWithListInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user); + partial void OnErrorCreateUsersWithListInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); /// /// Creates list of users with given input array @@ -789,6 +880,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithListInput(e); throw; } } @@ -836,18 +928,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeleteUser(exception, pathFormat, path, username); + bool suppressDefaultLog = false; + OnErrorDeleteUser(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username); + partial void OnErrorDeleteUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); /// /// Delete user This can only be done by the logged in user. @@ -915,6 +1010,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorDeleteUser(e); throw; } } @@ -962,18 +1058,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetUserByName(exception, pathFormat, path, username); + bool suppressDefaultLog = false; + OnErrorGetUserByName(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username); + partial void OnErrorGetUserByName(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); /// /// Get user by user name @@ -1051,6 +1150,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorGetUserByName(e); throw; } } @@ -1105,19 +1205,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorLoginUser(exception, pathFormat, path, username, password); + bool suppressDefaultLog = false; + OnErrorLoginUser(ref suppressDefaultLog, exception, pathFormat, path, username, password); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password); + partial void OnErrorLoginUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username, string password); /// /// Logs user into the system @@ -1203,6 +1306,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); + Events.ExecuteOnErrorLoginUser(e); throw; } } @@ -1234,17 +1338,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorLogoutUser(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorLogoutUser(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorLogoutUser(Exception exception, string pathFormat, string path); + partial void OnErrorLogoutUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Logs out current logged in user session @@ -1305,6 +1412,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorLogoutUser(e); throw; } } @@ -1359,19 +1467,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdateUser(exception, pathFormat, path, user, username); + bool suppressDefaultLog = false; + OnErrorUpdateUser(ref suppressDefaultLog, exception, pathFormat, path, user, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username); + partial void OnErrorUpdateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string username); /// /// Updated user This can only be done by the logged in user. @@ -1454,6 +1565,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + Events.ExecuteOnErrorUpdateUser(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 00000000000..dcfab667823 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/.openapi-generator/FILES index dc6273a3813..47b2b9b5c4f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/.openapi-generator/FILES @@ -22,6 +22,7 @@ src/Org.OpenAPITools/Client/ClientUtils.cs src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 9cd6b5b3f17..2dc5e241fad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -73,10 +73,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnList; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorList; + internal void ExecuteOnList(ApiResponse apiResponse) { OnList?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorList(Exception exception) + { + OnErrorList?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -156,18 +166,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorListDefaultImplementation(Exception exception, string pathFormat, string path, string personId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorList(exception, pathFormat, path, personId); + bool suppressDefaultLog = false; + OnErrorList(ref suppressDefaultLog, exception, pathFormat, path, personId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorList(Exception exception, string pathFormat, string path, string personId); + partial void OnErrorList(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string personId); /// /// @@ -244,6 +257,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorListDefaultImplementation(e, "/person/display/{personId}", uriBuilderLocalVar.Path, personId); + Events.ExecuteOnErrorList(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 00000000000..dcfab667823 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/.openapi-generator/FILES index ca078a2045e..59cc1ea25a0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/.openapi-generator/FILES @@ -22,6 +22,7 @@ src/Org.OpenAPITools/Client/ClientUtils.cs src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 21b4ff426b9..b02bf29c7cd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -71,10 +71,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnRootGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorRootGet; + internal void ExecuteOnRootGet(ApiResponse apiResponse) { OnRootGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorRootGet(Exception exception) + { + OnErrorRootGet?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -138,17 +148,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorRootGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorRootGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorRootGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorRootGet(Exception exception, string pathFormat, string path); + partial void OnErrorRootGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// @@ -218,6 +231,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorRootGetDefaultImplementation(e, "/", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorRootGet(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 00000000000..dcfab667823 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/.openapi-generator/FILES index ca078a2045e..59cc1ea25a0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/.openapi-generator/FILES @@ -22,6 +22,7 @@ src/Org.OpenAPITools/Client/ClientUtils.cs src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs src/Org.OpenAPITools/Client/Option.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs index 21b4ff426b9..b02bf29c7cd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -71,10 +71,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler>? OnRootGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorRootGet; + internal void ExecuteOnRootGet(ApiResponse apiResponse) { OnRootGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorRootGet(Exception exception) + { + OnErrorRootGet?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -138,17 +148,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorRootGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorRootGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorRootGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorRootGet(Exception exception, string pathFormat, string path); + partial void OnErrorRootGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// @@ -218,6 +231,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorRootGetDefaultImplementation(e, "/", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorRootGet(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 00000000000..dcfab667823 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-oneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES index 60c779c5ced..04ee5f80fe4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES @@ -118,6 +118,7 @@ src/Org.OpenAPITools/Client/ClientUtils.cs src/Org.OpenAPITools/Client/CookieContainer.cs src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs src/Org.OpenAPITools/Client/HostConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs src/Org.OpenAPITools/Client/HttpSigningToken.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index c8d804c412f..7975c5936ac 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -71,10 +71,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnCall123TestSpecialTags; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCall123TestSpecialTags; + internal void ExecuteOnCall123TestSpecialTags(ApiResponse apiResponse) { OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception) + { + OnErrorCall123TestSpecialTags?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -189,18 +199,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCall123TestSpecialTags(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorCall123TestSpecialTags(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCall123TestSpecialTags(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorCall123TestSpecialTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test special tags To test special tags and operation ID starting with number @@ -288,6 +301,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorCall123TestSpecialTags(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs index 784439aff14..33ff8b8df44 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -113,30 +113,60 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnFooGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFooGet; + internal void ExecuteOnFooGet(ApiResponse apiResponse) { OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFooGet(Exception exception) + { + OnErrorFooGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetCountry; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetCountry; + internal void ExecuteOnGetCountry(ApiResponse apiResponse) { OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetCountry(Exception exception) + { + OnErrorGetCountry?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnHello; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorHello; + internal void ExecuteOnHello(ApiResponse> apiResponse) { OnHello?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + + internal void ExecuteOnErrorHello(Exception exception) + { + OnErrorHello?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -235,17 +265,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFooGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorFooGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorFooGet(Exception exception, string pathFormat, string path); + partial void OnErrorFooGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// @@ -314,6 +347,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFooGet(e); throw; } } @@ -361,18 +395,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetCountry(exception, pathFormat, path, country); + bool suppressDefaultLog = false; + OnErrorGetCountry(ref suppressDefaultLog, exception, pathFormat, path, country); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country); + partial void OnErrorGetCountry(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string country); /// /// @@ -458,6 +495,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); + Events.ExecuteOnErrorGetCountry(e); throw; } } @@ -489,17 +527,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorHello(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorHello(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorHello(Exception exception, string pathFormat, string path); + partial void OnErrorHello(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Hello Hello @@ -568,6 +609,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorHello(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs index ec092a3fc0e..f3d60a343ea 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeApi.cs @@ -461,150 +461,300 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnFakeHealthGet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeHealthGet; + internal void ExecuteOnFakeHealthGet(ApiResponse apiResponse) { OnFakeHealthGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeHealthGet(Exception exception) + { + OnErrorFakeHealthGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterBooleanSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterBooleanSerialize; + internal void ExecuteOnFakeOuterBooleanSerialize(ApiResponse apiResponse) { OnFakeOuterBooleanSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterBooleanSerialize(Exception exception) + { + OnErrorFakeOuterBooleanSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterCompositeSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterCompositeSerialize; + internal void ExecuteOnFakeOuterCompositeSerialize(ApiResponse apiResponse) { OnFakeOuterCompositeSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterCompositeSerialize(Exception exception) + { + OnErrorFakeOuterCompositeSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterNumberSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterNumberSerialize; + internal void ExecuteOnFakeOuterNumberSerialize(ApiResponse apiResponse) { OnFakeOuterNumberSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterNumberSerialize(Exception exception) + { + OnErrorFakeOuterNumberSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnFakeOuterStringSerialize; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterStringSerialize; + internal void ExecuteOnFakeOuterStringSerialize(ApiResponse apiResponse) { OnFakeOuterStringSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorFakeOuterStringSerialize(Exception exception) + { + OnErrorFakeOuterStringSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnGetArrayOfEnums; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetArrayOfEnums; + internal void ExecuteOnGetArrayOfEnums(ApiResponse> apiResponse) { OnGetArrayOfEnums?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) + { + OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestBodyWithFileSchema; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithFileSchema; + internal void ExecuteOnTestBodyWithFileSchema(ApiResponse apiResponse) { OnTestBodyWithFileSchema?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestBodyWithFileSchema(Exception exception) + { + OnErrorTestBodyWithFileSchema?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestBodyWithQueryParams; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithQueryParams; + internal void ExecuteOnTestBodyWithQueryParams(ApiResponse apiResponse) { OnTestBodyWithQueryParams?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestBodyWithQueryParams(Exception exception) + { + OnErrorTestBodyWithQueryParams?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestClientModel; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClientModel; + internal void ExecuteOnTestClientModel(ApiResponse apiResponse) { OnTestClientModel?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestClientModel(Exception exception) + { + OnErrorTestClientModel?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestEndpointParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEndpointParameters; + internal void ExecuteOnTestEndpointParameters(ApiResponse apiResponse) { OnTestEndpointParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestEndpointParameters(Exception exception) + { + OnErrorTestEndpointParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestEnumParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEnumParameters; + internal void ExecuteOnTestEnumParameters(ApiResponse apiResponse) { OnTestEnumParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestEnumParameters(Exception exception) + { + OnErrorTestEnumParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestGroupParameters; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestGroupParameters; + internal void ExecuteOnTestGroupParameters(ApiResponse apiResponse) { OnTestGroupParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestGroupParameters(Exception exception) + { + OnErrorTestGroupParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestInlineAdditionalProperties; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestInlineAdditionalProperties; + internal void ExecuteOnTestInlineAdditionalProperties(ApiResponse apiResponse) { OnTestInlineAdditionalProperties?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestInlineAdditionalProperties(Exception exception) + { + OnErrorTestInlineAdditionalProperties?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestJsonFormData; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestJsonFormData; + internal void ExecuteOnTestJsonFormData(ApiResponse apiResponse) { OnTestJsonFormData?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorTestJsonFormData(Exception exception) + { + OnErrorTestJsonFormData?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnTestQueryParameterCollectionFormat; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestQueryParameterCollectionFormat; + internal void ExecuteOnTestQueryParameterCollectionFormat(ApiResponse apiResponse) { OnTestQueryParameterCollectionFormat?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception exception) + { + OnErrorTestQueryParameterCollectionFormat?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -703,17 +853,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeHealthGet(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorFakeHealthGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorFakeHealthGet(Exception exception, string pathFormat, string path); + partial void OnErrorFakeHealthGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Health check endpoint @@ -782,6 +935,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFakeHealthGet(e); throw; } } @@ -818,18 +972,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterBooleanSerialize(exception, pathFormat, path, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterBooleanSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterBooleanSerialize(Exception exception, string pathFormat, string path, Option body); + partial void OnErrorFakeOuterBooleanSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); /// /// Test serialization of outer boolean types @@ -916,6 +1073,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterBooleanSerialize(e); throw; } } @@ -963,18 +1121,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option outerComposite) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterCompositeSerialize(exception, pathFormat, path, outerComposite); + bool suppressDefaultLog = false; + OnErrorFakeOuterCompositeSerialize(ref suppressDefaultLog, exception, pathFormat, path, outerComposite); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterCompositeSerialize(Exception exception, string pathFormat, string path, Option outerComposite); + partial void OnErrorFakeOuterCompositeSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option outerComposite); /// /// Test serialization of object with outer number type @@ -1063,6 +1224,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + Events.ExecuteOnErrorFakeOuterCompositeSerialize(e); throw; } } @@ -1099,18 +1261,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterNumberSerialize(exception, pathFormat, path, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterNumberSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFakeOuterNumberSerialize(Exception exception, string pathFormat, string path, Option body); + partial void OnErrorFakeOuterNumberSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); /// /// Test serialization of outer number types @@ -1197,6 +1362,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterNumberSerialize(e); throw; } } @@ -1247,19 +1413,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFakeOuterStringSerialize(exception, pathFormat, path, requiredStringUuid, body); + bool suppressDefaultLog = false; + OnErrorFakeOuterStringSerialize(ref suppressDefaultLog, exception, pathFormat, path, requiredStringUuid, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorFakeOuterStringSerialize(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); + partial void OnErrorFakeOuterStringSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); /// /// Test serialization of outer string types @@ -1356,6 +1525,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + Events.ExecuteOnErrorFakeOuterStringSerialize(e); throw; } } @@ -1387,17 +1557,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetArrayOfEnums(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorGetArrayOfEnums(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorGetArrayOfEnums(Exception exception, string pathFormat, string path); + partial void OnErrorGetArrayOfEnums(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Array of Enums @@ -1466,6 +1639,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetArrayOfEnums(e); throw; } } @@ -1513,18 +1687,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestBodyWithFileSchema(exception, pathFormat, path, fileSchemaTestClass); + bool suppressDefaultLog = false; + OnErrorTestBodyWithFileSchema(ref suppressDefaultLog, exception, pathFormat, path, fileSchemaTestClass); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestBodyWithFileSchema(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + partial void OnErrorTestBodyWithFileSchema(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); /// /// For this test, the body for this request much reference a schema named `File`. @@ -1604,6 +1781,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + Events.ExecuteOnErrorTestBodyWithFileSchema(e); throw; } } @@ -1658,19 +1836,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestBodyWithQueryParams(exception, pathFormat, path, user, query); + bool suppressDefaultLog = false; + OnErrorTestBodyWithQueryParams(ref suppressDefaultLog, exception, pathFormat, path, user, query); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorTestBodyWithQueryParams(Exception exception, string pathFormat, string path, User user, string query); + partial void OnErrorTestBodyWithQueryParams(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string query); /// /// @@ -1758,6 +1939,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + Events.ExecuteOnErrorTestBodyWithQueryParams(e); throw; } } @@ -1805,18 +1987,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestClientModel(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorTestClientModel(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestClientModel(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorTestClientModel(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test \"client\" model To test \"client\" model @@ -1904,6 +2089,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClientModel(e); throw; } } @@ -2010,13 +2196,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestEndpointParameters(exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + bool suppressDefaultLog = false; + OnErrorTestEndpointParameters(ref suppressDefaultLog, exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2034,7 +2223,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestEndpointParameters(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); /// /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -2194,6 +2383,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + Events.ExecuteOnErrorTestEndpointParameters(e); throw; } } @@ -2282,13 +2472,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestEnumParameters(exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + bool suppressDefaultLog = false; + OnErrorTestEnumParameters(ref suppressDefaultLog, exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2300,7 +2493,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestEnumParameters(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); + partial void OnErrorTestEnumParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); /// /// To test enum parameters To test enum parameters @@ -2424,6 +2617,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + Events.ExecuteOnErrorTestEnumParameters(e); throw; } } @@ -2475,13 +2669,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestGroupParameters(exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + bool suppressDefaultLog = false; + OnErrorTestGroupParameters(ref suppressDefaultLog, exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -2491,7 +2688,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestGroupParameters(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); + partial void OnErrorTestGroupParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); /// /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) @@ -2595,6 +2792,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + Events.ExecuteOnErrorTestGroupParameters(e); throw; } } @@ -2642,18 +2840,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestInlineAdditionalProperties(exception, pathFormat, path, requestBody); + bool suppressDefaultLog = false; + OnErrorTestInlineAdditionalProperties(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestInlineAdditionalProperties(Exception exception, string pathFormat, string path, Dictionary requestBody); + partial void OnErrorTestInlineAdditionalProperties(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); /// /// test inline additionalProperties @@ -2733,6 +2934,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestInlineAdditionalProperties(e); throw; } } @@ -2787,19 +2989,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestJsonFormData(exception, pathFormat, path, param, param2); + bool suppressDefaultLog = false; + OnErrorTestJsonFormData(ref suppressDefaultLog, exception, pathFormat, path, param, param2); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorTestJsonFormData(Exception exception, string pathFormat, string path, string param, string param2); + partial void OnErrorTestJsonFormData(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string param, string param2); /// /// test json serialization of form data @@ -2889,6 +3094,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + Events.ExecuteOnErrorTestJsonFormData(e); throw; } } @@ -2984,13 +3190,16 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestQueryParameterCollectionFormat(exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + bool suppressDefaultLog = false; + OnErrorTestQueryParameterCollectionFormat(ref suppressDefaultLog, exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// @@ -3003,7 +3212,7 @@ namespace Org.OpenAPITools.Api /// /// /// - partial void OnErrorTestQueryParameterCollectionFormat(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); + partial void OnErrorTestQueryParameterCollectionFormat(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); /// /// To test the collection format in query parameters @@ -3103,6 +3312,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + Events.ExecuteOnErrorTestQueryParameterCollectionFormat(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index a54c516d8a3..f9103b3aef0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -71,10 +71,20 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnTestClassname; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClassname; + internal void ExecuteOnTestClassname(ApiResponse apiResponse) { OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorTestClassname(Exception exception) + { + OnErrorTestClassname?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -189,18 +199,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorTestClassname(exception, pathFormat, path, modelClient); + bool suppressDefaultLog = false; + OnErrorTestClassname(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorTestClassname(Exception exception, string pathFormat, string path, ModelClient modelClient); + partial void OnErrorTestClassname(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); /// /// To test class name in snake case To test class name in snake case @@ -303,6 +316,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClassname(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs index 4c86dadaa50..2bdddb195ae 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/PetApi.cs @@ -269,90 +269,180 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnAddPet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorAddPet; + internal void ExecuteOnAddPet(ApiResponse apiResponse) { OnAddPet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorAddPet(Exception exception) + { + OnErrorAddPet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnDeletePet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeletePet; + internal void ExecuteOnDeletePet(ApiResponse apiResponse) { OnDeletePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeletePet(Exception exception) + { + OnErrorDeletePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnFindPetsByStatus; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByStatus; + internal void ExecuteOnFindPetsByStatus(ApiResponse> apiResponse) { OnFindPetsByStatus?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorFindPetsByStatus(Exception exception) + { + OnErrorFindPetsByStatus?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnFindPetsByTags; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByTags; + internal void ExecuteOnFindPetsByTags(ApiResponse> apiResponse) { OnFindPetsByTags?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorFindPetsByTags(Exception exception) + { + OnErrorFindPetsByTags?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetPetById; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetPetById; + internal void ExecuteOnGetPetById(ApiResponse apiResponse) { OnGetPetById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetPetById(Exception exception) + { + OnErrorGetPetById?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUpdatePet; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePet; + internal void ExecuteOnUpdatePet(ApiResponse apiResponse) { OnUpdatePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUpdatePet(Exception exception) + { + OnErrorUpdatePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUpdatePetWithForm; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePetWithForm; + internal void ExecuteOnUpdatePetWithForm(ApiResponse apiResponse) { OnUpdatePetWithForm?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUpdatePetWithForm(Exception exception) + { + OnErrorUpdatePetWithForm?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUploadFile; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFile; + internal void ExecuteOnUploadFile(ApiResponse apiResponse) { OnUploadFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorUploadFile(Exception exception) + { + OnErrorUploadFile?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUploadFileWithRequiredFile; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFileWithRequiredFile; + internal void ExecuteOnUploadFileWithRequiredFile(ApiResponse apiResponse) { OnUploadFileWithRequiredFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) + { + OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -467,18 +557,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorAddPet(exception, pathFormat, path, pet); + bool suppressDefaultLog = false; + OnErrorAddPet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorAddPet(Exception exception, string pathFormat, string path, Pet pet); + partial void OnErrorAddPet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); /// /// Add a new pet to the store @@ -585,6 +678,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorAddPet(e); throw; } } @@ -635,19 +729,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option apiKey) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeletePet(exception, pathFormat, path, petId, apiKey); + bool suppressDefaultLog = false; + OnErrorDeletePet(ref suppressDefaultLog, exception, pathFormat, path, petId, apiKey); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorDeletePet(Exception exception, string pathFormat, string path, long petId, Option apiKey); + partial void OnErrorDeletePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option apiKey); /// /// Deletes a pet @@ -731,6 +828,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + Events.ExecuteOnErrorDeletePet(e); throw; } } @@ -778,18 +876,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFindPetsByStatus(exception, pathFormat, path, status); + bool suppressDefaultLog = false; + OnErrorFindPetsByStatus(ref suppressDefaultLog, exception, pathFormat, path, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFindPetsByStatus(Exception exception, string pathFormat, string path, List status); + partial void OnErrorFindPetsByStatus(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List status); /// /// Finds Pets by status Multiple status values can be provided with comma separated strings @@ -897,6 +998,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + Events.ExecuteOnErrorFindPetsByStatus(e); throw; } } @@ -944,18 +1046,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorFindPetsByTags(exception, pathFormat, path, tags); + bool suppressDefaultLog = false; + OnErrorFindPetsByTags(ref suppressDefaultLog, exception, pathFormat, path, tags); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorFindPetsByTags(Exception exception, string pathFormat, string path, List tags); + partial void OnErrorFindPetsByTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List tags); /// /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -1063,6 +1168,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + Events.ExecuteOnErrorFindPetsByTags(e); throw; } } @@ -1099,18 +1205,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetPetById(exception, pathFormat, path, petId); + bool suppressDefaultLog = false; + OnErrorGetPetById(ref suppressDefaultLog, exception, pathFormat, path, petId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetPetById(Exception exception, string pathFormat, string path, long petId); + partial void OnErrorGetPetById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId); /// /// Find pet by ID Returns a single pet @@ -1197,6 +1306,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + Events.ExecuteOnErrorGetPetById(e); throw; } } @@ -1244,18 +1354,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdatePet(exception, pathFormat, path, pet); + bool suppressDefaultLog = false; + OnErrorUpdatePet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorUpdatePet(Exception exception, string pathFormat, string path, Pet pet); + partial void OnErrorUpdatePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); /// /// Update an existing pet @@ -1362,6 +1475,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorUpdatePet(e); throw; } } @@ -1419,20 +1533,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option name, Option status) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdatePetWithForm(exception, pathFormat, path, petId, name, status); + bool suppressDefaultLog = false; + OnErrorUpdatePetWithForm(ref suppressDefaultLog, exception, pathFormat, path, petId, name, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUpdatePetWithForm(Exception exception, string pathFormat, string path, long petId, Option name, Option status); + partial void OnErrorUpdatePetWithForm(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option name, Option status); /// /// Updates a pet in the store with form data @@ -1537,6 +1654,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + Events.ExecuteOnErrorUpdatePetWithForm(e); throw; } } @@ -1594,20 +1712,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUploadFile(exception, pathFormat, path, petId, file, additionalMetadata); + bool suppressDefaultLog = false; + OnErrorUploadFile(ref suppressDefaultLog, exception, pathFormat, path, petId, file, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUploadFile(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); + partial void OnErrorUploadFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); /// /// uploads an image @@ -1720,6 +1841,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + Events.ExecuteOnErrorUploadFile(e); throw; } } @@ -1777,20 +1899,23 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUploadFileWithRequiredFile(exception, pathFormat, path, requiredFile, petId, additionalMetadata); + bool suppressDefaultLog = false; + OnErrorUploadFileWithRequiredFile(ref suppressDefaultLog, exception, pathFormat, path, requiredFile, petId, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// /// - partial void OnErrorUploadFileWithRequiredFile(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); /// /// uploads an image (required) @@ -1903,6 +2028,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + Events.ExecuteOnErrorUploadFileWithRequiredFile(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs index 8ab50aff5ea..47a994825d0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/StoreApi.cs @@ -138,40 +138,80 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnDeleteOrder; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteOrder; + internal void ExecuteOnDeleteOrder(ApiResponse apiResponse) { OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeleteOrder(Exception exception) + { + OnErrorDeleteOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler>> OnGetInventory; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetInventory; + internal void ExecuteOnGetInventory(ApiResponse> apiResponse) { OnGetInventory?.Invoke(this, new ApiResponseEventArgs>(apiResponse)); } + internal void ExecuteOnErrorGetInventory(Exception exception) + { + OnErrorGetInventory?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetOrderById; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetOrderById; + internal void ExecuteOnGetOrderById(ApiResponse apiResponse) { OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetOrderById(Exception exception) + { + OnErrorGetOrderById?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnPlaceOrder; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorPlaceOrder; + internal void ExecuteOnPlaceOrder(ApiResponse apiResponse) { OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorPlaceOrder(Exception exception) + { + OnErrorPlaceOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -286,18 +326,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeleteOrder(exception, pathFormat, path, orderId); + bool suppressDefaultLog = false; + OnErrorDeleteOrder(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorDeleteOrder(Exception exception, string pathFormat, string path, string orderId); + partial void OnErrorDeleteOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string orderId); /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -364,6 +407,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorDeleteOrder(e); throw; } } @@ -395,17 +439,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetInventory(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorGetInventory(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorGetInventory(Exception exception, string pathFormat, string path); + partial void OnErrorGetInventory(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Returns pet inventories by status Returns a map of status codes to quantities @@ -486,6 +533,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetInventory(e); throw; } } @@ -522,18 +570,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetOrderById(exception, pathFormat, path, orderId); + bool suppressDefaultLog = false; + OnErrorGetOrderById(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetOrderById(Exception exception, string pathFormat, string path, long orderId); + partial void OnErrorGetOrderById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long orderId); /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions @@ -608,6 +659,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorGetOrderById(e); throw; } } @@ -655,18 +707,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorPlaceOrder(exception, pathFormat, path, order); + bool suppressDefaultLog = false; + OnErrorPlaceOrder(ref suppressDefaultLog, exception, pathFormat, path, order); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorPlaceOrder(Exception exception, string pathFormat, string path, Order order); + partial void OnErrorPlaceOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Order order); /// /// Place an order for a pet @@ -755,6 +810,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); + Events.ExecuteOnErrorPlaceOrder(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs index e897250f4ad..1c341786c0a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/UserApi.cs @@ -234,80 +234,160 @@ namespace Org.OpenAPITools.Api /// public event EventHandler> OnCreateUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUser; + internal void ExecuteOnCreateUser(ApiResponse apiResponse) { OnCreateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUser(Exception exception) + { + OnErrorCreateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnCreateUsersWithArrayInput; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithArrayInput; + internal void ExecuteOnCreateUsersWithArrayInput(ApiResponse apiResponse) { OnCreateUsersWithArrayInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUsersWithArrayInput(Exception exception) + { + OnErrorCreateUsersWithArrayInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnCreateUsersWithListInput; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithListInput; + internal void ExecuteOnCreateUsersWithListInput(ApiResponse apiResponse) { OnCreateUsersWithListInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorCreateUsersWithListInput(Exception exception) + { + OnErrorCreateUsersWithListInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnDeleteUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteUser; + internal void ExecuteOnDeleteUser(ApiResponse apiResponse) { OnDeleteUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorDeleteUser(Exception exception) + { + OnErrorDeleteUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnGetUserByName; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetUserByName; + internal void ExecuteOnGetUserByName(ApiResponse apiResponse) { OnGetUserByName?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorGetUserByName(Exception exception) + { + OnErrorGetUserByName?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnLoginUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLoginUser; + internal void ExecuteOnLoginUser(ApiResponse apiResponse) { OnLoginUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorLoginUser(Exception exception) + { + OnErrorLoginUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnLogoutUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLogoutUser; + internal void ExecuteOnLogoutUser(ApiResponse apiResponse) { OnLogoutUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + internal void ExecuteOnErrorLogoutUser(Exception exception) + { + OnErrorLogoutUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// public event EventHandler> OnUpdateUser; + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdateUser; + internal void ExecuteOnUpdateUser(ApiResponse apiResponse) { OnUpdateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); } + + internal void ExecuteOnErrorUpdateUser(Exception exception) + { + OnErrorUpdateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } } /// @@ -422,18 +502,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUser(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUser(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUser(Exception exception, string pathFormat, string path, User user); + partial void OnErrorCreateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user); /// /// Create user This can only be done by the logged in user. @@ -513,6 +596,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUser(e); throw; } } @@ -560,18 +644,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUsersWithArrayInput(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUsersWithArrayInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUsersWithArrayInput(Exception exception, string pathFormat, string path, List user); + partial void OnErrorCreateUsersWithArrayInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); /// /// Creates list of users with given input array @@ -651,6 +738,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithArrayInput(e); throw; } } @@ -698,18 +786,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorCreateUsersWithListInput(exception, pathFormat, path, user); + bool suppressDefaultLog = false; + OnErrorCreateUsersWithListInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorCreateUsersWithListInput(Exception exception, string pathFormat, string path, List user); + partial void OnErrorCreateUsersWithListInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); /// /// Creates list of users with given input array @@ -789,6 +880,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithListInput(e); throw; } } @@ -836,18 +928,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorDeleteUser(exception, pathFormat, path, username); + bool suppressDefaultLog = false; + OnErrorDeleteUser(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorDeleteUser(Exception exception, string pathFormat, string path, string username); + partial void OnErrorDeleteUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); /// /// Delete user This can only be done by the logged in user. @@ -914,6 +1009,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorDeleteUser(e); throw; } } @@ -961,18 +1057,21 @@ namespace Org.OpenAPITools.Api /// private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorGetUserByName(exception, pathFormat, path, username); + bool suppressDefaultLog = false; + OnErrorGetUserByName(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// - partial void OnErrorGetUserByName(Exception exception, string pathFormat, string path, string username); + partial void OnErrorGetUserByName(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); /// /// Get user by user name @@ -1049,6 +1148,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorGetUserByName(e); throw; } } @@ -1103,19 +1203,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorLoginUser(exception, pathFormat, path, username, password); + bool suppressDefaultLog = false; + OnErrorLoginUser(ref suppressDefaultLog, exception, pathFormat, path, username, password); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorLoginUser(Exception exception, string pathFormat, string path, string username, string password); + partial void OnErrorLoginUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username, string password); /// /// Logs user into the system @@ -1200,6 +1303,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); + Events.ExecuteOnErrorLoginUser(e); throw; } } @@ -1231,17 +1335,20 @@ namespace Org.OpenAPITools.Api /// private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorLogoutUser(exception, pathFormat, path); + bool suppressDefaultLog = false; + OnErrorLogoutUser(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// - partial void OnErrorLogoutUser(Exception exception, string pathFormat, string path); + partial void OnErrorLogoutUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); /// /// Logs out current logged in user session @@ -1301,6 +1408,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorLogoutUser(e); throw; } } @@ -1355,19 +1463,22 @@ namespace Org.OpenAPITools.Api /// private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) { - Logger.LogError(exception, "An error occurred while sending the request to the server."); - OnErrorUpdateUser(exception, pathFormat, path, user, username); + bool suppressDefaultLog = false; + OnErrorUpdateUser(ref suppressDefaultLog, exception, pathFormat, path, user, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); } /// /// A partial method that gives developers a way to provide customized exception handling /// + /// /// /// /// /// /// - partial void OnErrorUpdateUser(Exception exception, string pathFormat, string path, User user, string username); + partial void OnErrorUpdateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string username); /// /// Updated user This can only be done by the logged in user. @@ -1450,6 +1561,7 @@ namespace Org.OpenAPITools.Api catch(Exception e) { OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + Events.ExecuteOnErrorUpdateUser(e); throw; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 00000000000..dcfab667823 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +}