Skip to content

Commit

Permalink
Merge pull request #545 from Lezune/users/Lezune/Clients-ChatCompleti…
Browse files Browse the repository at this point in the history
…ons-Update

CODE RUB: Clients ChatCompletions Exceptions Update v2.10.1
  • Loading branch information
glhays authored Jun 12, 2024
2 parents 4368072 + 6e31908 commit e8c5d71
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,48 @@ public async ValueTask<ChatCompletion> SendChatCompletionAsync(ChatCompletion ch
}
catch (ChatCompletionValidationException completionValidationException)
{
throw new ChatCompletionClientValidationException(
throw CreateChatCompletionClientValidationException(
completionValidationException.InnerException as Xeption);
}
catch (ChatCompletionDependencyValidationException completionDependencyValidationException)
{
throw new ChatCompletionClientValidationException(
throw CreateChatCompletionClientValidationException(
completionDependencyValidationException.InnerException as Xeption);
}
catch (ChatCompletionDependencyException completionDependencyException)
{
throw new ChatCompletionClientDependencyException(
throw CreateChatCompletionClientDependencyException(
completionDependencyException.InnerException as Xeption);
}
catch (ChatCompletionServiceException completionServiceException)
{
throw new ChatCompletionClientServiceException(
throw CreateChatCompletionClientServiceException(
completionServiceException.InnerException as Xeption);
}
}

private static ChatCompletionClientValidationException CreateChatCompletionClientValidationException(
Xeption innerException)
{
return new ChatCompletionClientValidationException(
message: "Chat completion client validation error occurred, fix errors and try again.",
innerException);
}

private static ChatCompletionClientDependencyException CreateChatCompletionClientDependencyException(
Xeption innerException)
{
return new ChatCompletionClientDependencyException(
message: "Chat completion dependency error occurred, contact support.",
innerException);
}

private static ChatCompletionClientServiceException CreateChatCompletionClientServiceException(
Xeption innerException)
{
return new ChatCompletionClientServiceException(
message: "Chat 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.ChatCompletions.Exceptions
/// </summary>
public class ChatCompletionClientDependencyException : Xeption
{
public ChatCompletionClientDependencyException(Xeption innerException)
: base(
message: "Chat completion dependency error occurred, contact support.",
innerException: innerException)
{ }

public ChatCompletionClientDependencyException(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 @@ public class ChatCompletionClientServiceException : Xeption
/// This exception is thrown when a service error occurs while using the Chat completion client.
/// For example, if there is a problem with the server or any other service failure.
/// </summary>
public ChatCompletionClientServiceException(Xeption innerException)
: base(
message: "Chat completion client service error occurred, contact support.",
innerException: innerException)
{ }

public ChatCompletionClientServiceException(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 @@ public class ChatCompletionClientValidationException : Xeption
/// This exception is thrown when a validation error occurs while using the Chat completion client.
/// For example, if required data is missing or invalid.
/// </summary>
public ChatCompletionClientValidationException(Xeption innerException)
: base(
message: "Chat completion client validation error occurred, fix errors and try again.",
innerException: innerException)
{ }

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

0 comments on commit e8c5d71

Please sign in to comment.