From dc51a5072672c92cd57f871bed666548db2c2be5 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 02:48:08 -0700 Subject: [PATCH 01/25] Updated ExcessiveCallImageGenerationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/ExcessiveCallImageGenerationException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ExcessiveCallImageGenerationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ExcessiveCallImageGenerationException.cs index e037587b..7888a00e 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ExcessiveCallImageGenerationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ExcessiveCallImageGenerationException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class ExcessiveCallImageGenerationException : Xeption { - public ExcessiveCallImageGenerationException(Exception innerException) - : base( - message: "Excessive call error occurred, limit your calls.", - innerException: innerException) - { } - public ExcessiveCallImageGenerationException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..9c2b5d2c 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -66,7 +66,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) { var excessiveCallImageGenerationException = - new ExcessiveCallImageGenerationException(httpResponseTooManyRequestsException); + new ExcessiveCallImageGenerationException( + message: "Excessive call error occurred, limit your calls.", + httpResponseTooManyRequestsException); throw new ImageGenerationDependencyValidationException(excessiveCallImageGenerationException); } From a5202c69847e894b7a05187b936cd222228a5fbe Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 02:53:15 -0700 Subject: [PATCH 02/25] Updated FailedImageGenerationServiceException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/FailedImageGenerationServiceException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedImageGenerationServiceException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedImageGenerationServiceException.cs index 5fbacb1b..ffd643ee 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedImageGenerationServiceException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedImageGenerationServiceException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class FailedImageGenerationServiceException : Xeption { - public FailedImageGenerationServiceException(Exception innerException) - : base( - message: "Failed image generation service error occurred, contact support.", - innerException: innerException) - { } - public FailedImageGenerationServiceException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..2db3623a 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -80,7 +80,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (Exception exception) { var failedImageGenerationServiceException = - new FailedImageGenerationServiceException(exception); + new FailedImageGenerationServiceException( + message: "Failed image generation service error occurred, contact support.", + exception); throw new ImageGenerationServiceException(failedImageGenerationServiceException); } From 09c962af64b99b1e63c575a87cdbe016ca55ff3c Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 02:58:12 -0700 Subject: [PATCH 03/25] Updated FailedServerImageGenerationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/FailedServerImageGenerationException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedServerImageGenerationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedServerImageGenerationException.cs index 358ad603..488ad22a 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedServerImageGenerationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/FailedServerImageGenerationException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class FailedServerImageGenerationException : Xeption { - public FailedServerImageGenerationException(Exception innerException) - : base( - message: "Failed image generation server error occurred, contact support.", - innerException: innerException) - { } - public FailedServerImageGenerationException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..4197909e 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -73,7 +73,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseException httpResponseException) { var failedServerImageGenerationException = - new FailedServerImageGenerationException(httpResponseException); + new FailedServerImageGenerationException( + message: "Failed image generation server error occurred, contact support.", + httpResponseException); throw new ImageGenerationDependencyException(failedServerImageGenerationException); } From 10e28f7e1cc6a012577564530b82be474cf327ff Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:01:57 -0700 Subject: [PATCH 04/25] Updated ImageGenerationDependencyException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../ImageGenerationDependencyException.cs | 6 ------ .../ImageGenerationService.Exceptions.cs | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyException.cs index 9849da89..00b4328f 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyException.cs @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class ImageGenerationDependencyException : Xeption { - public ImageGenerationDependencyException(Xeption innerException) - : base( - message: "Image generation dependency error occurred, contact support.", - innerException: innerException) - { } - public ImageGenerationDependencyException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..61aab367 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -33,21 +33,27 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var invalidConfigurationImageGenerationException = new InvalidConfigurationImageGenerationException(httpResponseUrlNotFoundException); - throw new ImageGenerationDependencyException(invalidConfigurationImageGenerationException); + throw new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + invalidConfigurationImageGenerationException); } catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedImageGenerationException = new UnauthorizedImageGenerationException(httpResponseUnauthorizedException); - throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); + throw new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + unauthorizedImageGenerationException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedImageGenerationException = new UnauthorizedImageGenerationException(httpResponseForbiddenException); - throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); + throw new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + unauthorizedImageGenerationException); } catch (HttpResponseNotFoundException httpResponseNotFoundException) { @@ -75,7 +81,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var failedServerImageGenerationException = new FailedServerImageGenerationException(httpResponseException); - throw new ImageGenerationDependencyException(failedServerImageGenerationException); + throw new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + failedServerImageGenerationException); } catch (Exception exception) { From 092a0edc09a3ff4e8f01f4f9c244d6f8e6f49947 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:05:38 -0700 Subject: [PATCH 05/25] Updated ImageGenerationDependencyValidationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../ImageGenerationDependencyValidationException.cs | 6 ------ .../ImageGenerationService.Exceptions.cs | 12 +++++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyValidationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyValidationException.cs index 39955e84..b79d757c 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyValidationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationDependencyValidationException.cs @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class ImageGenerationDependencyValidationException : Xeption { - public ImageGenerationDependencyValidationException(Xeption innerException) - : base( - message: "Image generation dependency validation error occurred, fix errors and try again.", - innerException: innerException) - { } - public ImageGenerationDependencyValidationException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..51f790c3 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -54,21 +54,27 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var notFoundImageGenerationException = new NotFoundImageGenerationException(httpResponseNotFoundException); - throw new ImageGenerationDependencyValidationException(notFoundImageGenerationException); + throw new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + notFoundImageGenerationException); } catch (HttpResponseBadRequestException httpResponseBadRequestException) { var invalidImageGenerationException = new InvalidImageGenerationException(httpResponseBadRequestException); - throw new ImageGenerationDependencyValidationException(invalidImageGenerationException); + throw new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + invalidImageGenerationException); } catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) { var excessiveCallImageGenerationException = new ExcessiveCallImageGenerationException(httpResponseTooManyRequestsException); - throw new ImageGenerationDependencyValidationException(excessiveCallImageGenerationException); + throw new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + excessiveCallImageGenerationException); } catch (HttpResponseException httpResponseException) { From f322a7824281dbf6870d8b6ee1b07600e666ef85 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:09:08 -0700 Subject: [PATCH 06/25] Updated ImageGenerationServiceException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/ImageGenerationServiceException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationServiceException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationServiceException.cs index 69822ee7..742828a6 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationServiceException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationServiceException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class ImageGenerationServiceException : Xeption { - public ImageGenerationServiceException(Exception innerException) - : base( - message: "Image generation service error occurred, contact support.", - innerException: innerException) - { } - public ImageGenerationServiceException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..cc98e09c 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -82,7 +82,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var failedImageGenerationServiceException = new FailedImageGenerationServiceException(exception); - throw new ImageGenerationServiceException(failedImageGenerationServiceException); + throw new ImageGenerationServiceException( + message: "Image generation service error occurred, contact support.", + failedImageGenerationServiceException); } } } From 34d65908bc6494874f2f93bce18144c9167a671b Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:13:17 -0700 Subject: [PATCH 07/25] Updated ImageGenerationValidationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/ImageGenerationValidationException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationValidationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationValidationException.cs index e7fe4028..0ea23539 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationValidationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/ImageGenerationValidationException.cs @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class ImageGenerationValidationException : Xeption { - public ImageGenerationValidationException(Xeption innerException) - : base( - message: "Image generation validation error occurred, fix errors and try again.", - innerException: innerException) - { } - public ImageGenerationValidationException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..4e83c98a 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -22,11 +22,15 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti } catch (NullImageGenerationException nullImageGenerationException) { - throw new ImageGenerationValidationException(nullImageGenerationException); + throw new ImageGenerationValidationException( + message: "Image generation validation error occurred, fix errors and try again.", + nullImageGenerationException); } catch (InvalidImageGenerationException invalidImageGenerationException) { - throw new ImageGenerationValidationException(invalidImageGenerationException); + throw new ImageGenerationValidationException( + message: "Image generation validation error occurred, fix errors and try again.", + invalidImageGenerationException); } catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) { From 29bffa289c453b0c10687d2ea6fb91bdfeed0bbb Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:21:24 -0700 Subject: [PATCH 08/25] Updated InvalidConfigurationImageGenerationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../InvalidConfigurationImageGenerationException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidConfigurationImageGenerationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidConfigurationImageGenerationException.cs index 68649641..2048b0fe 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidConfigurationImageGenerationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidConfigurationImageGenerationException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class InvalidConfigurationImageGenerationException : Xeption { - public InvalidConfigurationImageGenerationException(Exception innerException) - : base( - message: "Invalid image generation configuration error occurred, contact support.", - innerException: innerException) - { } - public InvalidConfigurationImageGenerationException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..14353965 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -31,7 +31,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) { var invalidConfigurationImageGenerationException = - new InvalidConfigurationImageGenerationException(httpResponseUrlNotFoundException); + new InvalidConfigurationImageGenerationException( + message: "Invalid image generation configuration error occurred, contact support.", + httpResponseUrlNotFoundException); throw new ImageGenerationDependencyException(invalidConfigurationImageGenerationException); } From ba6f05e7b3c577de7226d1772217b93be7a3ba48 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:26:31 -0700 Subject: [PATCH 09/25] Updated InvalidImageGenerationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- ...mageGenerationServiceTests.Validations.Generate.cs | 6 ++++-- .../Exceptions/InvalidImageGenerationException.cs | 11 ++--------- .../ImageGenerationService.Exceptions.cs | 4 +++- .../ImageGenerationService.Validations.cs | 4 +++- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs index e1cb5395..4418a738 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs @@ -58,7 +58,8 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsNullAsync( invalidImageGeneration.Request = null; var invalidImageGenerationException = - new InvalidImageGenerationException(); + new InvalidImageGenerationException( + message: "Invalid image generation error occurred, fix errors and try again."); invalidImageGenerationException.AddData( key: nameof(ImageGeneration.Request), @@ -106,7 +107,8 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsInvalidAsy }; var invalidImageGenerationException = - new InvalidImageGenerationException(); + new InvalidImageGenerationException( + message: "Invalid image generation error occurred, fix errors and try again."); invalidImageGenerationException.AddData( key: nameof(ImageGeneration.Request.Prompt), diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidImageGenerationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidImageGenerationException.cs index f2b751dd..52bfe881 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidImageGenerationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/InvalidImageGenerationException.cs @@ -9,15 +9,8 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class InvalidImageGenerationException : Xeption { - public InvalidImageGenerationException() - : base( - message: "Invalid image generation error occurred, fix errors and try again.") - { } - - public InvalidImageGenerationException(Exception innerException) - : base( - message: "Invalid image generation error occurred, fix errors and try again.", - innerException: innerException) + public InvalidImageGenerationException(string message) + : base(message) { } public InvalidImageGenerationException(string message, Exception innerException) diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..fb0d009a 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -59,7 +59,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseBadRequestException httpResponseBadRequestException) { var invalidImageGenerationException = - new InvalidImageGenerationException(httpResponseBadRequestException); + new InvalidImageGenerationException( + message: "Invalid image generation error occurred, fix errors and try again.", + httpResponseBadRequestException); throw new ImageGenerationDependencyValidationException(invalidImageGenerationException); } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs index b72804f1..009ddf65 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs @@ -45,7 +45,9 @@ private static void ValidateImageGenerationIsNotNull(ImageGeneration imageGenera private static void Validate(params (dynamic Rule, string Parameter)[] validations) { - var invalidImageGenerationException = new InvalidImageGenerationException(); + var invalidImageGenerationException = + new InvalidImageGenerationException( + message: "Invalid image generation error occurred, fix errors and try again."); foreach ((dynamic rule, string parameter) in validations) { From c5fcb5f319b45be2ecb768910c82ba893a3176a7 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:30:09 -0700 Subject: [PATCH 10/25] Updated NotFoundImageGenerationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/NotFoundImageGenerationException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NotFoundImageGenerationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NotFoundImageGenerationException.cs index 14b4b345..40c68aff 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NotFoundImageGenerationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NotFoundImageGenerationException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class NotFoundImageGenerationException : Xeption { - public NotFoundImageGenerationException(Exception innerException) - : base( - message: "Not found image generation error occurred, fix errors and try again.", - innerException: innerException) - { } - public NotFoundImageGenerationException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..4df8ae0d 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -52,7 +52,9 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseNotFoundException httpResponseNotFoundException) { var notFoundImageGenerationException = - new NotFoundImageGenerationException(httpResponseNotFoundException); + new NotFoundImageGenerationException( + message: "Not found image generation error occurred, fix errors and try again.", + httpResponseNotFoundException); throw new ImageGenerationDependencyValidationException(notFoundImageGenerationException); } From 4dbb98c6d7967d7552e96a645380026d5b0d783a Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:33:35 -0700 Subject: [PATCH 11/25] Updated NullImageGenerationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../ImageGenerationServiceTests.Validations.Generate.cs | 3 ++- .../Exceptions/NullImageGenerationException.cs | 5 ++--- .../ImageGenerations/ImageGenerationService.Validations.cs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs index e1cb5395..500d5813 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs @@ -21,7 +21,8 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfImageGenerationIsNu ImageGeneration nullImageGeneration = null; var nullImageGenerationException = - new NullImageGenerationException(); + new NullImageGenerationException( + message: "Image generation is null."); var expectedImageGenerationValidationException = new ImageGenerationValidationException( diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NullImageGenerationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NullImageGenerationException.cs index e57104ad..fefd419c 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NullImageGenerationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/NullImageGenerationException.cs @@ -8,9 +8,8 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class NullImageGenerationException : Xeption { - public NullImageGenerationException() - : base( - message: "Image generation is null.") + public NullImageGenerationException(string message) + : base(message) { } public NullImageGenerationException(string message, Xeption innerException) diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs index b72804f1..af334785 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Validations.cs @@ -27,7 +27,8 @@ private static void ValidateImageGenerationIsNotNull(ImageGeneration imageGenera { if (imageGeneration is null) { - throw new NullImageGenerationException(); + throw new NullImageGenerationException( + message: "Image generation is null."); } } From 83af75411aef1d4542c7fdf6e5ec1ec0f7dc53be Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 30 May 2024 03:37:54 -0700 Subject: [PATCH 12/25] Updated UnauthorizedImageGenerationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/UnauthorizedImageGenerationException.cs | 6 ------ .../ImageGenerations/ImageGenerationService.Exceptions.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/UnauthorizedImageGenerationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/UnauthorizedImageGenerationException.cs index 500c83b4..83229366 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/UnauthorizedImageGenerationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ImageGenerations/Exceptions/UnauthorizedImageGenerationException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Except { public class UnauthorizedImageGenerationException : Xeption { - public UnauthorizedImageGenerationException(Exception innerException) - : base( - message: "Unauthorized image generation request, fix errors and try again.", - innerException: innerException) - { } - public UnauthorizedImageGenerationException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index ab06432d..3333dc49 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -38,14 +38,18 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedImageGenerationException = - new UnauthorizedImageGenerationException(httpResponseUnauthorizedException); + new UnauthorizedImageGenerationException( + message: "Unauthorized image generation request, fix errors and try again.", + httpResponseUnauthorizedException); throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedImageGenerationException = - new UnauthorizedImageGenerationException(httpResponseForbiddenException); + new UnauthorizedImageGenerationException( + message: "Unauthorized image generation request, fix errors and try again.", + httpResponseForbiddenException); throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); } From 641830b0b9a572e8d70bccad8669ed3f03011f94 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 05:23:54 -0700 Subject: [PATCH 13/25] Added create methods to both ImageGenerationService.Exceptions.cs and ImageGenerationServiceTests.cs as well as refactored code --- ...erationServiceTests.Exceptions.Generate.cs | 15 ++++++-------- .../ImageGenerationServiceTests.cs | 9 +++++++++ .../ImageGenerationService.Exceptions.cs | 20 +++++++++++-------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs index b694bf65..3d12bba6 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs @@ -31,9 +31,8 @@ private async Task ShouldThrowDependencyExceptionOnGenerateIfUrlNotFoundAsync() innerException: httpResponseUrlNotFoundException); var expectedImageGenerationDependencyException = - new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", - innerException: invalidConfigurationImageGenerationException); + createImageGenerationDependencyException( + innerException: invalidConfigurationImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -75,9 +74,8 @@ private async Task ShouldThrowDependencyExceptionOnGenerateIfUnauthorizedAsync( innerException: unauthorizedException); var expectedImageGenerationDependencyException = - new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", - innerException: unauthorizedImageGenerationException); + createImageGenerationDependencyException( + innerException: unauthorizedImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -253,9 +251,8 @@ private async Task ShouldThrowDependencyExceptionOnGenerateIfHttpResponseErrorOc innerException: httpResponseException); var expectedImageGenerationDependencyException = - new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", - innerException: failedServerImageGenerationException); + createImageGenerationDependencyException( + innerException: failedServerImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index 2dcf7195..b49f3aec 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -13,8 +13,10 @@ using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; +using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; using Standard.AI.OpenAI.Services.Foundations.ImageGenerations; using Tynamix.ObjectFiller; +using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ImageGenerations @@ -107,5 +109,12 @@ public static TheoryData UnauthorizedExceptions() new HttpResponseForbiddenException() }; } + + private static ImageGenerationDependencyException createImageGenerationDependencyException(Xeption innerException) + { + return new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + innerException); + } } } \ No newline at end of file diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index 61aab367..a9f4727c 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -7,6 +7,7 @@ using RESTFulSense.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; +using Xeptions; namespace Standard.AI.OpenAI.Services.Foundations.ImageGenerations { @@ -33,8 +34,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var invalidConfigurationImageGenerationException = new InvalidConfigurationImageGenerationException(httpResponseUrlNotFoundException); - throw new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", + throw createImageGenerationDependencyException( invalidConfigurationImageGenerationException); } catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) @@ -42,8 +42,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var unauthorizedImageGenerationException = new UnauthorizedImageGenerationException(httpResponseUnauthorizedException); - throw new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", + throw createImageGenerationDependencyException( unauthorizedImageGenerationException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) @@ -51,8 +50,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var unauthorizedImageGenerationException = new UnauthorizedImageGenerationException(httpResponseForbiddenException); - throw new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", + throw createImageGenerationDependencyException( unauthorizedImageGenerationException); } catch (HttpResponseNotFoundException httpResponseNotFoundException) @@ -81,8 +79,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var failedServerImageGenerationException = new FailedServerImageGenerationException(httpResponseException); - throw new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", + throw createImageGenerationDependencyException( failedServerImageGenerationException); } catch (Exception exception) @@ -93,5 +90,12 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti throw new ImageGenerationServiceException(failedImageGenerationServiceException); } } + + private static ImageGenerationDependencyException createImageGenerationDependencyException(Xeption innerException) + { + return new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + innerException); + } } } \ No newline at end of file From ac5ee7dd7e4a743d91af468ea4e728d8e6ab8534 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 05:29:45 -0700 Subject: [PATCH 14/25] Added create methods to both ImageGenerationService.Exceptions.cs and ImageGenerationServiceTests.cs as well as refactored code --- ...enerationServiceTests.Exceptions.Generate.cs | 15 ++++++--------- .../ImageGenerationServiceTests.cs | 9 +++++++++ .../ImageGenerationService.Exceptions.cs | 17 +++++++++++------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs index b694bf65..4bc725af 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs @@ -120,9 +120,8 @@ private async Task ShouldThrowDependencyValidationExceptionOnGenerateIfImageGene innerException: httpResponseNotFoundException); var expectedImageGenerationDependencyValidationException = - new ImageGenerationDependencyValidationException( - message: "Image generation dependency validation error occurred, fix errors and try again.", - innerException: notFoundImageGenerationException); + createImageGenerationDependencyValidationException( + innerException: notFoundImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -165,9 +164,8 @@ private async Task ShouldThrowDependencyValidationExceptionOnGenerateIfBadReques innerException: httpResponseBadRequestException); var expectedImageGenerationDependencyValidationException = - new ImageGenerationDependencyValidationException( - message: "Image generation dependency validation error occurred, fix errors and try again.", - innerException: invalidImageGenerationException); + createImageGenerationDependencyValidationException( + innerException: invalidImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -210,9 +208,8 @@ private async Task ShouldThrowDependencyValidationExceptionOnGenerateIfTooManyRe innerException: httpResponseTooManyRequestsException); var expectedImageGenerationDependencyValidationException = - new ImageGenerationDependencyValidationException( - message: "Image generation dependency validation error occurred, fix errors and try again.", - innerException: excessiveCallImageGenerationException); + createImageGenerationDependencyValidationException( + innerException: excessiveCallImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index 2dcf7195..b2eb42e5 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -13,8 +13,10 @@ using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; +using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; using Standard.AI.OpenAI.Services.Foundations.ImageGenerations; using Tynamix.ObjectFiller; +using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ImageGenerations @@ -107,5 +109,12 @@ public static TheoryData UnauthorizedExceptions() new HttpResponseForbiddenException() }; } + + private static ImageGenerationDependencyValidationException createImageGenerationDependencyValidationException(Xeption innerException) + { + return new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + innerException); + } } } \ No newline at end of file diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index 51f790c3..aeeb77dc 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -7,6 +7,7 @@ using RESTFulSense.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; +using Xeptions; namespace Standard.AI.OpenAI.Services.Foundations.ImageGenerations { @@ -54,8 +55,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var notFoundImageGenerationException = new NotFoundImageGenerationException(httpResponseNotFoundException); - throw new ImageGenerationDependencyValidationException( - message: "Image generation dependency validation error occurred, fix errors and try again.", + throw createImageGenerationDependencyValidationException( notFoundImageGenerationException); } catch (HttpResponseBadRequestException httpResponseBadRequestException) @@ -63,8 +63,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var invalidImageGenerationException = new InvalidImageGenerationException(httpResponseBadRequestException); - throw new ImageGenerationDependencyValidationException( - message: "Image generation dependency validation error occurred, fix errors and try again.", + throw createImageGenerationDependencyValidationException( invalidImageGenerationException); } catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) @@ -72,8 +71,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var excessiveCallImageGenerationException = new ExcessiveCallImageGenerationException(httpResponseTooManyRequestsException); - throw new ImageGenerationDependencyValidationException( - message: "Image generation dependency validation error occurred, fix errors and try again.", + throw createImageGenerationDependencyValidationException( excessiveCallImageGenerationException); } catch (HttpResponseException httpResponseException) @@ -91,5 +89,12 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti throw new ImageGenerationServiceException(failedImageGenerationServiceException); } } + + private static ImageGenerationDependencyValidationException createImageGenerationDependencyValidationException(Xeption innerException) + { + return new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + innerException); + } } } \ No newline at end of file From 4c392094f299aa040e1aae6bb90a5f329853e24f Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 05:35:36 -0700 Subject: [PATCH 15/25] Added create methods to both ImageGenerationService.Exceptions.cs and ImageGenerationServiceTests.cs as well as refactored code --- ...GenerationServiceTests.Validations.Generate.cs | 15 ++++++--------- .../ImageGenerationServiceTests.cs | 9 +++++++++ .../ImageGenerationService.Exceptions.cs | 14 ++++++++++---- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs index e1cb5395..e5abe0a6 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs @@ -24,9 +24,8 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfImageGenerationIsNu new NullImageGenerationException(); var expectedImageGenerationValidationException = - new ImageGenerationValidationException( - message: "Image generation validation error occurred, fix errors and try again.", - innerException: nullImageGenerationException); + createImageGenerationValidationException( + innerException: nullImageGenerationException); // when ValueTask generateImageTask = @@ -65,9 +64,8 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsNullAsync( values: "Value is required"); var expectedImageGenerationValidationException = - new ImageGenerationValidationException( - message: "Image generation validation error occurred, fix errors and try again.", - innerException: invalidImageGenerationException); + createImageGenerationValidationException( + innerException: invalidImageGenerationException); // when ValueTask generateImageTask = @@ -113,9 +111,8 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsInvalidAsy values: "Value is required"); var expectedImageGenerationValidationException = - new ImageGenerationValidationException( - message: "Image generation validation error occurred, fix errors and try again.", - innerException: invalidImageGenerationException); + createImageGenerationValidationException( + innerException: invalidImageGenerationException); // when ValueTask generateImageTask = diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index 2dcf7195..6fa7230a 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -13,8 +13,10 @@ using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; +using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; using Standard.AI.OpenAI.Services.Foundations.ImageGenerations; using Tynamix.ObjectFiller; +using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ImageGenerations @@ -107,5 +109,12 @@ public static TheoryData UnauthorizedExceptions() new HttpResponseForbiddenException() }; } + + private static ImageGenerationValidationException createImageGenerationValidationException(Xeption innerException) + { + return new ImageGenerationValidationException( + message: "Image generation validation error occurred, fix errors and try again.", + innerException); + } } } \ No newline at end of file diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index 4e83c98a..9a4c617c 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -7,6 +7,7 @@ using RESTFulSense.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; +using Xeptions; namespace Standard.AI.OpenAI.Services.Foundations.ImageGenerations { @@ -22,14 +23,12 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti } catch (NullImageGenerationException nullImageGenerationException) { - throw new ImageGenerationValidationException( - message: "Image generation validation error occurred, fix errors and try again.", + throw createImageGenerationValidationException( nullImageGenerationException); } catch (InvalidImageGenerationException invalidImageGenerationException) { - throw new ImageGenerationValidationException( - message: "Image generation validation error occurred, fix errors and try again.", + throw createImageGenerationValidationException( invalidImageGenerationException); } catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) @@ -89,5 +88,12 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti throw new ImageGenerationServiceException(failedImageGenerationServiceException); } } + + private static ImageGenerationValidationException createImageGenerationValidationException(Xeption innerException) + { + return new ImageGenerationValidationException( + message: "Image generation validation error occurred, fix errors and try again.", + innerException); + } } } \ No newline at end of file From ab6ad11c1b7a8c377780b8c2ec43a71ee351d9a4 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 05:40:33 -0700 Subject: [PATCH 16/25] Added create methods to both ImageGenerationService.Exceptions.cs and ImageGenerationServiceTests.cs as well as refactored code --- .../ImageGenerationServiceTests.Validations.Generate.cs | 6 ++---- .../ImageGenerations/ImageGenerationServiceTests.cs | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs index 4418a738..ac04c34d 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs @@ -58,8 +58,7 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsNullAsync( invalidImageGeneration.Request = null; var invalidImageGenerationException = - new InvalidImageGenerationException( - message: "Invalid image generation error occurred, fix errors and try again."); + createInvalidImageGenerationException(); invalidImageGenerationException.AddData( key: nameof(ImageGeneration.Request), @@ -107,8 +106,7 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsInvalidAsy }; var invalidImageGenerationException = - new InvalidImageGenerationException( - message: "Invalid image generation error occurred, fix errors and try again."); + createInvalidImageGenerationException(); invalidImageGenerationException.AddData( key: nameof(ImageGeneration.Request.Prompt), diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index 2dcf7195..b1d2a087 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -13,6 +13,7 @@ using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; +using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; using Standard.AI.OpenAI.Services.Foundations.ImageGenerations; using Tynamix.ObjectFiller; using Xunit; @@ -107,5 +108,11 @@ public static TheoryData UnauthorizedExceptions() new HttpResponseForbiddenException() }; } + + private static InvalidImageGenerationException createInvalidImageGenerationException() + { + return new InvalidImageGenerationException( + message: "Invalid image generation error occurred, fix errors and try again."); + } } } \ No newline at end of file From fef16cb4cbb6e3711fb225ca6f99aac2a63312e2 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 05:46:22 -0700 Subject: [PATCH 17/25] Added create methods to both ImageGenerationService.Exceptions.cs and ImageGenerationServiceTests.cs as well as refactored code --- .../ImageGenerationService.Exceptions.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index 3333dc49..829dc110 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -38,8 +38,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedImageGenerationException = - new UnauthorizedImageGenerationException( - message: "Unauthorized image generation request, fix errors and try again.", + createUnauthorizedImageGenerationException( httpResponseUnauthorizedException); throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); @@ -47,8 +46,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedImageGenerationException = - new UnauthorizedImageGenerationException( - message: "Unauthorized image generation request, fix errors and try again.", + createUnauthorizedImageGenerationException( httpResponseForbiddenException); throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); @@ -89,5 +87,12 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti throw new ImageGenerationServiceException(failedImageGenerationServiceException); } } + + private static UnauthorizedImageGenerationException createUnauthorizedImageGenerationException(Exception innerException) + { + return new UnauthorizedImageGenerationException( + message: "Unauthorized image generation request, fix errors and try again.", + innerException); + } } } \ No newline at end of file From 4cde18dfaf77dc4312bcfe5dac1d32485cb5f3f5 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:16:18 -0700 Subject: [PATCH 18/25] Updated create method to adhere to method naming standards --- .../ImageGenerationService.Exceptions.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index a9f4727c..3abf647f 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -34,7 +34,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var invalidConfigurationImageGenerationException = new InvalidConfigurationImageGenerationException(httpResponseUrlNotFoundException); - throw createImageGenerationDependencyException( + throw CreateImageGenerationDependencyException( invalidConfigurationImageGenerationException); } catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) @@ -42,7 +42,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var unauthorizedImageGenerationException = new UnauthorizedImageGenerationException(httpResponseUnauthorizedException); - throw createImageGenerationDependencyException( + throw CreateImageGenerationDependencyException( unauthorizedImageGenerationException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) @@ -50,7 +50,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var unauthorizedImageGenerationException = new UnauthorizedImageGenerationException(httpResponseForbiddenException); - throw createImageGenerationDependencyException( + throw CreateImageGenerationDependencyException( unauthorizedImageGenerationException); } catch (HttpResponseNotFoundException httpResponseNotFoundException) @@ -79,7 +79,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var failedServerImageGenerationException = new FailedServerImageGenerationException(httpResponseException); - throw createImageGenerationDependencyException( + throw CreateImageGenerationDependencyException( failedServerImageGenerationException); } catch (Exception exception) @@ -91,7 +91,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti } } - private static ImageGenerationDependencyException createImageGenerationDependencyException(Xeption innerException) + private static ImageGenerationDependencyException CreateImageGenerationDependencyException(Xeption innerException) { return new ImageGenerationDependencyException( message: "Image generation dependency error occurred, contact support.", From f9d3b697e3b786027036e248dae96c1a77d2560e Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:16:31 -0700 Subject: [PATCH 19/25] Reverted Unit Test files to original state --- ...eGenerationServiceTests.Exceptions.Generate.cs | 15 +++++++++------ .../ImageGenerationServiceTests.cs | 9 --------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs index 3d12bba6..b694bf65 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs @@ -31,8 +31,9 @@ private async Task ShouldThrowDependencyExceptionOnGenerateIfUrlNotFoundAsync() innerException: httpResponseUrlNotFoundException); var expectedImageGenerationDependencyException = - createImageGenerationDependencyException( - innerException: invalidConfigurationImageGenerationException); + new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + innerException: invalidConfigurationImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -74,8 +75,9 @@ private async Task ShouldThrowDependencyExceptionOnGenerateIfUnauthorizedAsync( innerException: unauthorizedException); var expectedImageGenerationDependencyException = - createImageGenerationDependencyException( - innerException: unauthorizedImageGenerationException); + new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + innerException: unauthorizedImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -251,8 +253,9 @@ private async Task ShouldThrowDependencyExceptionOnGenerateIfHttpResponseErrorOc innerException: httpResponseException); var expectedImageGenerationDependencyException = - createImageGenerationDependencyException( - innerException: failedServerImageGenerationException); + new ImageGenerationDependencyException( + message: "Image generation dependency error occurred, contact support.", + innerException: failedServerImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index b49f3aec..2dcf7195 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -13,10 +13,8 @@ using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; -using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; using Standard.AI.OpenAI.Services.Foundations.ImageGenerations; using Tynamix.ObjectFiller; -using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ImageGenerations @@ -109,12 +107,5 @@ public static TheoryData UnauthorizedExceptions() new HttpResponseForbiddenException() }; } - - private static ImageGenerationDependencyException createImageGenerationDependencyException(Xeption innerException) - { - return new ImageGenerationDependencyException( - message: "Image generation dependency error occurred, contact support.", - innerException); - } } } \ No newline at end of file From bb8b461848a29dbf98f2d0d3e526969b108559c8 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:18:25 -0700 Subject: [PATCH 20/25] Reverted Unit Test files to original state --- ...eGenerationServiceTests.Exceptions.Generate.cs | 15 +++++++++------ .../ImageGenerationServiceTests.cs | 9 --------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs index 4bc725af..b694bf65 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Exceptions.Generate.cs @@ -120,8 +120,9 @@ private async Task ShouldThrowDependencyValidationExceptionOnGenerateIfImageGene innerException: httpResponseNotFoundException); var expectedImageGenerationDependencyValidationException = - createImageGenerationDependencyValidationException( - innerException: notFoundImageGenerationException); + new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + innerException: notFoundImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -164,8 +165,9 @@ private async Task ShouldThrowDependencyValidationExceptionOnGenerateIfBadReques innerException: httpResponseBadRequestException); var expectedImageGenerationDependencyValidationException = - createImageGenerationDependencyValidationException( - innerException: invalidImageGenerationException); + new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + innerException: invalidImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( @@ -208,8 +210,9 @@ private async Task ShouldThrowDependencyValidationExceptionOnGenerateIfTooManyRe innerException: httpResponseTooManyRequestsException); var expectedImageGenerationDependencyValidationException = - createImageGenerationDependencyValidationException( - innerException: excessiveCallImageGenerationException); + new ImageGenerationDependencyValidationException( + message: "Image generation dependency validation error occurred, fix errors and try again.", + innerException: excessiveCallImageGenerationException); this.openAIBrokerMock.Setup(broker => broker.PostImageGenerationRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index b2eb42e5..2dcf7195 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -13,10 +13,8 @@ using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; -using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; using Standard.AI.OpenAI.Services.Foundations.ImageGenerations; using Tynamix.ObjectFiller; -using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ImageGenerations @@ -109,12 +107,5 @@ public static TheoryData UnauthorizedExceptions() new HttpResponseForbiddenException() }; } - - private static ImageGenerationDependencyValidationException createImageGenerationDependencyValidationException(Xeption innerException) - { - return new ImageGenerationDependencyValidationException( - message: "Image generation dependency validation error occurred, fix errors and try again.", - innerException); - } } } \ No newline at end of file From 67487193e54973d20be8c709b96bba32ccf3267a Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:19:51 -0700 Subject: [PATCH 21/25] Updated create method to adhere to method naming standards --- .../ImageGenerations/ImageGenerationService.Exceptions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index aeeb77dc..f48263e8 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -55,7 +55,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var notFoundImageGenerationException = new NotFoundImageGenerationException(httpResponseNotFoundException); - throw createImageGenerationDependencyValidationException( + throw CreateImageGenerationDependencyValidationException( notFoundImageGenerationException); } catch (HttpResponseBadRequestException httpResponseBadRequestException) @@ -63,7 +63,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var invalidImageGenerationException = new InvalidImageGenerationException(httpResponseBadRequestException); - throw createImageGenerationDependencyValidationException( + throw CreateImageGenerationDependencyValidationException( invalidImageGenerationException); } catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) @@ -71,7 +71,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti var excessiveCallImageGenerationException = new ExcessiveCallImageGenerationException(httpResponseTooManyRequestsException); - throw createImageGenerationDependencyValidationException( + throw CreateImageGenerationDependencyValidationException( excessiveCallImageGenerationException); } catch (HttpResponseException httpResponseException) @@ -90,7 +90,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti } } - private static ImageGenerationDependencyValidationException createImageGenerationDependencyValidationException(Xeption innerException) + private static ImageGenerationDependencyValidationException CreateImageGenerationDependencyValidationException(Xeption innerException) { return new ImageGenerationDependencyValidationException( message: "Image generation dependency validation error occurred, fix errors and try again.", From 1f0bce911ea2e7c6819df40c10371eb27b5e76de Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:22:23 -0700 Subject: [PATCH 22/25] Updated create method to adhere to method naming standards --- .../ImageGenerations/ImageGenerationService.Exceptions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index 9a4c617c..d75a28f3 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -23,12 +23,12 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti } catch (NullImageGenerationException nullImageGenerationException) { - throw createImageGenerationValidationException( + throw CreateImageGenerationValidationException( nullImageGenerationException); } catch (InvalidImageGenerationException invalidImageGenerationException) { - throw createImageGenerationValidationException( + throw CreateImageGenerationValidationException( invalidImageGenerationException); } catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) @@ -89,7 +89,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti } } - private static ImageGenerationValidationException createImageGenerationValidationException(Xeption innerException) + private static ImageGenerationValidationException CreateImageGenerationValidationException(Xeption innerException) { return new ImageGenerationValidationException( message: "Image generation validation error occurred, fix errors and try again.", From fc335ef34c4c8deca918c37eeefbf6e881e9a4a1 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:22:54 -0700 Subject: [PATCH 23/25] Reverted Unit Test files to original state --- ...GenerationServiceTests.Validations.Generate.cs | 15 +++++++++------ .../ImageGenerationServiceTests.cs | 9 --------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs index e5abe0a6..e1cb5395 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs @@ -24,8 +24,9 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfImageGenerationIsNu new NullImageGenerationException(); var expectedImageGenerationValidationException = - createImageGenerationValidationException( - innerException: nullImageGenerationException); + new ImageGenerationValidationException( + message: "Image generation validation error occurred, fix errors and try again.", + innerException: nullImageGenerationException); // when ValueTask generateImageTask = @@ -64,8 +65,9 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsNullAsync( values: "Value is required"); var expectedImageGenerationValidationException = - createImageGenerationValidationException( - innerException: invalidImageGenerationException); + new ImageGenerationValidationException( + message: "Image generation validation error occurred, fix errors and try again.", + innerException: invalidImageGenerationException); // when ValueTask generateImageTask = @@ -111,8 +113,9 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsInvalidAsy values: "Value is required"); var expectedImageGenerationValidationException = - createImageGenerationValidationException( - innerException: invalidImageGenerationException); + new ImageGenerationValidationException( + message: "Image generation validation error occurred, fix errors and try again.", + innerException: invalidImageGenerationException); // when ValueTask generateImageTask = diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index 6fa7230a..2dcf7195 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -13,10 +13,8 @@ using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations; using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations; -using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions; using Standard.AI.OpenAI.Services.Foundations.ImageGenerations; using Tynamix.ObjectFiller; -using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ImageGenerations @@ -109,12 +107,5 @@ public static TheoryData UnauthorizedExceptions() new HttpResponseForbiddenException() }; } - - private static ImageGenerationValidationException createImageGenerationValidationException(Xeption innerException) - { - return new ImageGenerationValidationException( - message: "Image generation validation error occurred, fix errors and try again.", - innerException); - } } } \ No newline at end of file From 223dee450ebfce78c0bf05a7b6efef03d0050efe Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:27:03 -0700 Subject: [PATCH 24/25] Updated create method to adhere to method naming standards --- .../ImageGenerationServiceTests.Validations.Generate.cs | 4 ++-- .../ImageGenerations/ImageGenerationServiceTests.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs index ac04c34d..91e81981 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.Validations.Generate.cs @@ -58,7 +58,7 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsNullAsync( invalidImageGeneration.Request = null; var invalidImageGenerationException = - createInvalidImageGenerationException(); + CreateInvalidImageGenerationException(); invalidImageGenerationException.AddData( key: nameof(ImageGeneration.Request), @@ -106,7 +106,7 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsInvalidAsy }; var invalidImageGenerationException = - createInvalidImageGenerationException(); + CreateInvalidImageGenerationException(); invalidImageGenerationException.AddData( key: nameof(ImageGeneration.Request.Prompt), diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs index b1d2a087..52c03567 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ImageGenerations/ImageGenerationServiceTests.cs @@ -109,7 +109,7 @@ public static TheoryData UnauthorizedExceptions() }; } - private static InvalidImageGenerationException createInvalidImageGenerationException() + private static InvalidImageGenerationException CreateInvalidImageGenerationException() { return new InvalidImageGenerationException( message: "Invalid image generation error occurred, fix errors and try again."); From 99f86df3d169cdd7ab9ebea1e6c79878cd05e704 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 09:29:51 -0700 Subject: [PATCH 25/25] Updated create method to adhere to method naming standards --- .../ImageGenerations/ImageGenerationService.Exceptions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs index 829dc110..785d3766 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ImageGenerations/ImageGenerationService.Exceptions.cs @@ -38,7 +38,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedImageGenerationException = - createUnauthorizedImageGenerationException( + CreateUnauthorizedImageGenerationException( httpResponseUnauthorizedException); throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); @@ -46,7 +46,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedImageGenerationException = - createUnauthorizedImageGenerationException( + CreateUnauthorizedImageGenerationException( httpResponseForbiddenException); throw new ImageGenerationDependencyException(unauthorizedImageGenerationException); @@ -88,7 +88,7 @@ private async ValueTask TryCatch(ReturningImageGenerationFuncti } } - private static UnauthorizedImageGenerationException createUnauthorizedImageGenerationException(Exception innerException) + private static UnauthorizedImageGenerationException CreateUnauthorizedImageGenerationException(Exception innerException) { return new UnauthorizedImageGenerationException( message: "Unauthorized image generation request, fix errors and try again.",