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: Foundations AudioTranscriptions Exceptions Update v2.10.1 #555

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e023763
Updated AudioTranscriptionServiceException class by removing construc…
Lezune May 29, 2024
5667382
Updated AudioTranscriptionValidationException class by removing const…
Lezune May 29, 2024
0d13c07
Updated FailedAudioTranscriptionServiceException class by removing co…
Lezune May 29, 2024
cdd7bf4
Updated InvalidAudioTranscriptionException class by removing construc…
Lezune May 29, 2024
4fc50aa
Updated InvalidConfigurationAudioTranscriptionException class by remo…
Lezune May 29, 2024
5cf9dd5
Updated NullAudioTranscriptionException class by removing constructor…
Lezune May 29, 2024
fd7bcb9
Updated UnauthorizedAudioTranscriptionException class by removing con…
Lezune May 29, 2024
a3a9487
Updated AudioTranscriptionDependencyException class by removing const…
Lezune May 30, 2024
6f04789
Updated AudioTranscriptionDependencyValidationException class by remo…
Lezune May 30, 2024
191a530
Added create methods to both AIModelService.Exceptions.cs and AIModel…
Lezune May 31, 2024
6fa5968
Added create methods to both AIModelService.Exceptions.cs and AIModel…
Lezune May 31, 2024
4704585
Added create methods to both AudioTranscriptions.Exceptions.cs and Au…
Lezune May 31, 2024
65396bf
Added create methods to both AudioTranscriptions.Exceptions.cs and Au…
Lezune May 31, 2024
c4d328b
Added create methods to both AudioTranscriptions.Exceptions.cs and Au…
Lezune May 31, 2024
babce74
Reverted Unit Test files and updated create method declaration and ca…
Lezune Jun 6, 2024
967b3fa
Reverted Unit Test files and updated create method declaration and ca…
Lezune Jun 6, 2024
6de4765
Reverted Unit Test files and updated create method declaration and ca…
Lezune Jun 6, 2024
ff8f0ac
Removed one of the constructors so the class can adhere to anemic mod…
Lezune Jun 6, 2024
c61e4ab
Updated create method to adhere to method naming standards
Lezune Jun 6, 2024
0605421
Merge branch 'users/Lezune/Foundations-AudioTranscriptionValidationEx…
Lezune Jun 10, 2024
491020a
Resolved merge conflicts with users/Lezune/Foundations-AudioTranscrip…
Lezune Jun 10, 2024
5e998d0
Resolved merge conflicts with users/Lezune/Foundations-AudioTranscrip…
Lezune Jun 10, 2024
b48e02d
Merge branch 'users/Lezune/Foundations-AudioTranscriptions-ExcessiveC…
Lezune Jun 10, 2024
fe4d8d2
Merge branch 'users/Lezune/Foundations-AudioTranscriptions-FailedAudi…
Lezune Jun 10, 2024
5c67956
Merge branch 'users/Lezune/Foundations-AudioTranscriptions-InvalidAud…
Lezune Jun 10, 2024
96b5c0e
Reverted Unit Test files to original state and updated method calls t…
Lezune Jun 10, 2024
7855949
Merge branch 'users/Lezune/Foundations-AudioTranscriptions-InvalidCon…
Lezune Jun 10, 2024
2c40225
Merge branch 'users/Lezune/Foundations-AudioTranscriptions-NullAudioT…
Lezune Jun 10, 2024
ca62942
Resolved merge conflicts, Updated & Refactored code
Lezune Jun 10, 2024
e540d8e
Refactored Code
Lezune Jun 11, 2024
8f770a8
Refactored Code
Lezune Jun 11, 2024
081bb5a
Refactored Code
Lezune Jun 11, 2024
067cb25
Removed extra line
Lezune Jun 12, 2024
d185443
Added line break above return statements.
Lezune Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfAudioTranscriptionIsNul
// given
AudioTranscription audioTranscription = null;

var nullAudioTranscriptionException = new NullAudioTranscriptionException();
var nullAudioTranscriptionException = new NullAudioTranscriptionException(
message: "Audio transcription is null.");

var exceptedAudioTranscriptionValidationException =
new AudioTranscriptionValidationException(
Expand Down Expand Up @@ -56,7 +57,9 @@ private async Task ShouldThrowValidationExceptionOnSendIfAudioTranscriptionReque
Request = null
};

var invalidAudioTranscriptionException = new InvalidAudioTranscriptionException();
var invalidAudioTranscriptionException =
new InvalidAudioTranscriptionException(
message: "Audio transcription is invalid.");

invalidAudioTranscriptionException.AddData(
key: nameof(AudioTranscription.Request),
Expand Down Expand Up @@ -103,7 +106,9 @@ private async Task ShouldThrowValidationExceptionOnSendIfAudioTranscriptionReque
}
};

var invalidAudioTranscriptionException = new InvalidAudioTranscriptionException();
var invalidAudioTranscriptionException =
new InvalidAudioTranscriptionException(
message: "Audio transcription is invalid.");

invalidAudioTranscriptionException.AddData(
key: nameof(AudioTranscriptionRequest.FileName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using RESTFulSense.Exceptions;
using Standard.AI.OpenAI.Brokers.OpenAIs;
using Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions;
using Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exceptions;
using Standard.AI.OpenAI.Models.Services.Foundations.ExternalAudioTranscriptions;
using Standard.AI.OpenAI.Services.Foundations.AudioTranscriptions;
using Tynamix.ObjectFiller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class AudioTranscriptionDependencyException : Xeption
{
public AudioTranscriptionDependencyException(Xeption innerException)
: base(
message: "Audio transcription dependency error occurred, contact support.",
innerException: innerException)
{ }

public AudioTranscriptionDependencyException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class AudioTranscriptionDependencyValidationException : Xeption
{
public AudioTranscriptionDependencyValidationException(Xeption innerException)
: base(
message: "Chat completion dependency validation error occurred, fix errors and try again.",
innerException: innerException)
{ }

public AudioTranscriptionDependencyValidationException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class AudioTranscriptionServiceException : Xeption
{
public AudioTranscriptionServiceException(Exception innerException)
: base(
message: "Audio transcription service error occurred, contact support.",
innerException: innerException)
{ }

public AudioTranscriptionServiceException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class AudioTranscriptionValidationException : Xeption
{
public AudioTranscriptionValidationException(Xeption innerException)
: base(
message: "Audio transcription validation error occurred, fix errors and try again.",
innerException: innerException)
{ }

public AudioTranscriptionValidationException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class ExcessiveCallAudioTranscriptionException : Xeption
{
public ExcessiveCallAudioTranscriptionException(Exception innerException)
: base(
message: "Excessive call error occurred, limit your calls.",
innerException: innerException)
{ }

public ExcessiveCallAudioTranscriptionException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class FailedAudioTranscriptionServiceException : Xeption
{
public FailedAudioTranscriptionServiceException(Exception innerException)
: base(
message: "Failed Audio Transcription Service Exception occurred, please contact support for assistance.",
innerException: innerException)
{ }

public FailedAudioTranscriptionServiceException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class InvalidAudioTranscriptionException : Xeption
{
public InvalidAudioTranscriptionException()
: base(
message: "Audio transcription is invalid.")
{ }

public InvalidAudioTranscriptionException(Exception innerException)
: base(
message: "Audio transcription is invalid.",
innerException: innerException)
public InvalidAudioTranscriptionException(string message)
: base(message)
{ }

public InvalidAudioTranscriptionException(string message, Exception innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class InvalidConfigurationAudioTranscriptionException : Xeption
{
public InvalidConfigurationAudioTranscriptionException(Exception innerException)
: base(
message: "Invalid audio transcription configuration error occurred, contact support.",
innerException: innerException)
{ }

public InvalidConfigurationAudioTranscriptionException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class NullAudioTranscriptionException : Xeption
{
public NullAudioTranscriptionException()
: base(
message: "Audio transcription is null.")
public NullAudioTranscriptionException(string message)
: base(message)
{ }

public NullAudioTranscriptionException(string message, Xeption innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exc
#pragma warning disable RCS1194 // Implement exception constructors.
public class UnauthorizedAudioTranscriptionException : Xeption
{
public UnauthorizedAudioTranscriptionException(Exception innerException)
: base(
message: "Unauthorized audio transcription request, fix errors and try again.",
innerException: innerException)
{ }

public UnauthorizedAudioTranscriptionException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RESTFulSense.Exceptions;
using Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions;
using Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exceptions;
using Xeptions;

namespace Standard.AI.OpenAI.Services.Foundations.AudioTranscriptions
{
Expand All @@ -23,54 +24,111 @@ private static async ValueTask<AudioTranscription> TryCatch(
}
catch (NullAudioTranscriptionException nullAudioTranscriptionException)
{
throw new AudioTranscriptionValidationException(nullAudioTranscriptionException);
throw CreateAudioTranscriptionValidationException(
nullAudioTranscriptionException);
}
catch (InvalidAudioTranscriptionException invalidAudioTranscriptionException)
{
throw new AudioTranscriptionValidationException(invalidAudioTranscriptionException);
throw CreateAudioTranscriptionValidationException(
invalidAudioTranscriptionException);
}
catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException)
{
var invalidConfigurationAudioTranscriptionException =
new InvalidConfigurationAudioTranscriptionException(httpResponseUrlNotFoundException);
new InvalidConfigurationAudioTranscriptionException(
message: "Invalid audio transcription configuration error occurred, contact support.",
httpResponseUrlNotFoundException);

throw new AudioTranscriptionDependencyException(invalidConfigurationAudioTranscriptionException);
throw CreateAudioTranscriptionDependencyException(
invalidConfigurationAudioTranscriptionException);
}
catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException)
{
var unauthorizedAudioTranscriptionException =
new UnauthorizedAudioTranscriptionException(httpResponseUnauthorizedException);
new UnauthorizedAudioTranscriptionException(
message: "Unauthorized audio transcription request, fix errors and try again.",
httpResponseUnauthorizedException);

throw new AudioTranscriptionDependencyException(unauthorizedAudioTranscriptionException);
throw CreateAudioTranscriptionDependencyException(
unauthorizedAudioTranscriptionException);
}
catch (HttpResponseForbiddenException httpResponseForbiddenException)
{
var unauthorizedAudioTranscriptionException =
new UnauthorizedAudioTranscriptionException(httpResponseForbiddenException);
new UnauthorizedAudioTranscriptionException(
message: "Unauthorized audio transcription request, fix errors and try again.",
httpResponseForbiddenException);

throw new AudioTranscriptionDependencyException(unauthorizedAudioTranscriptionException);
throw CreateAudioTranscriptionDependencyException(
unauthorizedAudioTranscriptionException);
}
catch (HttpResponseBadRequestException httpResponseBadRequestException)
{
var invalidAudioTranscriptionException =
new InvalidAudioTranscriptionException(httpResponseBadRequestException);
new InvalidAudioTranscriptionException(
message: "Audio transcription is invalid.",
httpResponseBadRequestException);

throw new AudioTranscriptionDependencyValidationException(invalidAudioTranscriptionException);
throw CreateAudioTranscriptionDependencyValidationException(
invalidAudioTranscriptionException);
}
catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException)
{
var excessiveCallAudioTranscriptionException =
new ExcessiveCallAudioTranscriptionException(httpResponseTooManyRequestsException);
new ExcessiveCallAudioTranscriptionException(
message: "Excessive call error occurred, limit your calls.",
httpResponseTooManyRequestsException);

throw new AudioTranscriptionDependencyValidationException(excessiveCallAudioTranscriptionException);
throw CreateAudioTranscriptionDependencyValidationException(
excessiveCallAudioTranscriptionException);
}
catch (Exception exception)
{
var failedAudioTranscriptionServiceException =
new FailedAudioTranscriptionServiceException(exception);
new FailedAudioTranscriptionServiceException(
message: "Failed Audio Transcription Service Exception occurred," +
" please contact support for assistance.",
exception);

throw new AudioTranscriptionServiceException(failedAudioTranscriptionServiceException);
throw CreateAudioTranscriptionServiceException(
failedAudioTranscriptionServiceException);
}
}

private static AudioTranscriptionValidationException
CreateAudioTranscriptionValidationException(Xeption innerException)
{

return new AudioTranscriptionValidationException(
message: "Audio transcription validation error occurred, fix errors and try again.",
innerException);
}

private static AudioTranscriptionDependencyException
CreateAudioTranscriptionDependencyException(Xeption innerException)
{

return new AudioTranscriptionDependencyException(
message: "Audio transcription dependency error occurred, contact support.",
innerException);
}

private static AudioTranscriptionDependencyValidationException
CreateAudioTranscriptionDependencyValidationException(Xeption innerException)
{

return new AudioTranscriptionDependencyValidationException(
message: "Chat completion dependency validation error occurred, fix errors and try again.",
innerException);
}

private static AudioTranscriptionServiceException
CreateAudioTranscriptionServiceException(Xeption innerException)
{

return new AudioTranscriptionServiceException(
Lezune marked this conversation as resolved.
Show resolved Hide resolved
message: "Audio transcription service error occurred, contact support.",
innerException);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ private static void ValidateAudioTranscriptionIsNotNull(AudioTranscription audio
{
if (audioTranscription is null)
{
throw new NullAudioTranscriptionException();
throw new NullAudioTranscriptionException(
message: "Audio transcription is null.");
}
}

Expand All @@ -48,7 +49,9 @@ private static void ValidateAudioTranscriptionIsNotNull(AudioTranscription audio

private static void Validate(params (dynamic Rule, string Parameter)[] validations)
{
InvalidAudioTranscriptionException invalidAudioTranscriptionException = new InvalidAudioTranscriptionException();
InvalidAudioTranscriptionException invalidAudioTranscriptionException =
new InvalidAudioTranscriptionException(
message: "Audio transcription is invalid.");

foreach ((dynamic rule, string parameter) in validations)
{
Expand Down
Loading