Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODE RUB: Client Completions Exceptions Update v2.10.1 #544

Merged
32 changes: 28 additions & 4 deletions Standard.AI.OpenAI/Clients/Completions/CompletionsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,48 @@ public async ValueTask<Completion> PromptCompletionAsync(Completion completion)
}
catch (CompletionValidationException completionValidationException)
{
throw new CompletionClientValidationException(
throw CreateCompletionClientValidationException(
completionValidationException.InnerException as Xeption);
}
catch (CompletionDependencyValidationException completionDependencyValidationException)
{
throw new CompletionClientValidationException(
throw CreateCompletionClientValidationException(
completionDependencyValidationException.InnerException as Xeption);
}
catch (CompletionDependencyException completionDependencyException)
{
throw new CompletionClientDependencyException(
throw CreateCompletionClientDependencyException(
completionDependencyException.InnerException as Xeption);
}
catch (CompletionServiceException completionServiceException)
{
throw new CompletionClientServiceException(
throw CreateCompletionClientServiceException(
completionServiceException.InnerException as Xeption);
}
}

private static CompletionClientValidationException CreateCompletionClientValidationException(
Xeption innerException)
{
return new CompletionClientValidationException(
message: "Completion client validation error occurred, fix errors and try again.",
innerException);
}

private static CompletionClientDependencyException CreateCompletionClientDependencyException(
Xeption innerException)
{
return new CompletionClientDependencyException(
message: "Completion dependency error occurred, contact support.",
innerException);
}

private static CompletionClientServiceException CreateCompletionClientServiceException(
Xeption innerException)
{
return new CompletionClientServiceException(
message: "Completion client service error occurred, contact support.",
innerException);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ namespace Standard.AI.OpenAI.Models.Clients.Completions.Exceptions
/// </summary>
public class CompletionClientDependencyException : Xeption
{
public CompletionClientDependencyException(Xeption innerException)
: base(
message: "Completion dependency error occurred, contact support.",
innerException: innerException)
{ }

public CompletionClientDependencyException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ namespace Standard.AI.OpenAI.Models.Clients.Completions.Exceptions
/// </summary>
public class CompletionClientServiceException : Xeption
{
public CompletionClientServiceException(Xeption innerException)
: base(
message: "Completion client service error occurred, contact support.",
innerException: innerException)
{ }

public CompletionClientServiceException(string message, Xeption innerException)
: base(message: message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ namespace Standard.AI.OpenAI.Models.Clients.Completions.Exceptions
/// </summary>
public class CompletionClientValidationException : Xeption
{
public CompletionClientValidationException(Xeption innerException)
: base(
message: "Completion client validation error occurred, fix errors and try again.",
innerException: innerException)
{ }

public CompletionClientValidationException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Loading