Skip to content

Commit

Permalink
Merge pull request #550 from Lezune/users/Lezune/Orchestrations-AIFil…
Browse files Browse the repository at this point in the history
…es-Update

CODE RUB: Orchestrations AIFiles Exceptions Update v2.10.1
  • Loading branch information
glhays authored Jun 12, 2024
2 parents 49ee3e9 + 48faec6 commit 6fdccc8
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ private async Task ShouldThrowValidationExceptionOnRemoveFileIfFileIdIsInvalid(s
{
// given
var invalidAiFileOrchestrationException =
new InvalidAIFileOrchestrationException();
new InvalidAIFileOrchestrationException(
message: "AI file is invalid.");

invalidAiFileOrchestrationException.AddData(
key: nameof(AIFile.Response.Id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ private async Task ShouldThrowValidationExceptionOnUploadIfFileIsNullAsync()
AIFile nullAIFile = null;

var nullAIFileOrchestrationException =
new NullAIFileOrchestrationException();
new NullAIFileOrchestrationException(
message: "AI file is null.");

var expectedAIFileOrchestrationValidationException =
new AIFileOrchestrationValidationException(
Expand Down Expand Up @@ -59,8 +60,9 @@ private async Task ShouldThrowValidationExceptionOnUploadIfRequestIsNullAsync()
// given
var invalidAIFile = new AIFile();

var invalidAIFileOrchestrationException =
new InvalidAIFileOrchestrationException();
var invalidAIFileOrchestrationException =
new InvalidAIFileOrchestrationException(
message: "AI file is invalid.");

invalidAIFileOrchestrationException.AddData(
key: nameof(AIFileRequest),
Expand Down Expand Up @@ -110,7 +112,8 @@ private async Task ShouldThrowValidationExceptionIfRequestIsInvalidAsync(
invalidAIFile.Request.Name = invalidName;

var invalidAIFileOrchestrationException =
new InvalidAIFileOrchestrationException();
new InvalidAIFileOrchestrationException(
message: "AI file is invalid.");

invalidAIFileOrchestrationException.AddData(
key: nameof(AIFileRequest.Name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Standard.AI.OpenAI.Models.Services.Foundations.AIFiles;
using Standard.AI.OpenAI.Models.Services.Foundations.AIFiles.Exceptions;
using Standard.AI.OpenAI.Models.Services.Foundations.LocalFiles.Exceptions;
using Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions;
using Standard.AI.OpenAI.Services.Foundations.AIFiles;
using Standard.AI.OpenAI.Services.Foundations.LocalFiles;
using Standard.AI.OpenAI.Services.Orchestrations.AIFiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions
{
public class AIFileOrchestrationDependencyException : Xeption
{
public AIFileOrchestrationDependencyException(Xeption innerException)
: base(
message: "AI File dependency error occurred, contact support.",
innerException: innerException)
{ }

public AIFileOrchestrationDependencyException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions
{
public class AIFileOrchestrationDependencyValidationException : Xeption
{
public AIFileOrchestrationDependencyValidationException(Xeption innerException)
: base(
message: "AI file dependency validation error occurred, fix errors and try again.",
innerException: innerException)
{ }

public AIFileOrchestrationDependencyValidationException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions
{
public class AIFileOrchestrationServiceException : Xeption
{
public AIFileOrchestrationServiceException(Xeption innerException)
: base(
message: "AI File error occurred, contact support.",
innerException: innerException)
{ }

public AIFileOrchestrationServiceException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions
{
public class AIFileOrchestrationValidationException : Xeption
{
public AIFileOrchestrationValidationException(Xeption innerException)
: base(
message: "AI file validation error occurred, fix errors and try again.",
innerException: innerException)
{ }

public AIFileOrchestrationValidationException(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.Orchestrations.AIFiles.Exceptions
{
public class FailedAIFileOrchestrationServiceException : Xeption
{
public FailedAIFileOrchestrationServiceException(Exception innerException)
: base(
message: "Failed AI file service error occurred, contact support.",
innerException: innerException)
{ }

public FailedAIFileOrchestrationServiceException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
namespace Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions
{
public class InvalidAIFileOrchestrationException : Xeption
{
public InvalidAIFileOrchestrationException()
: base(
message: "AI file is invalid.")
{
public InvalidAIFileOrchestrationException(string message)
: base(message)
{ }

public InvalidAIFileOrchestrationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ namespace Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions
{
internal class NullAIFileOrchestrationException : Xeption
{
public NullAIFileOrchestrationException()
: base(
message: "AI file is null.")
public NullAIFileOrchestrationException(string message)
: base(message)
{ }

public NullAIFileOrchestrationException(string message, Xeption innerException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,62 @@ private async ValueTask<AIFile> TryCatch(ReturningAIFileFunction returningAIFile
}
catch (NullAIFileOrchestrationException nullAIFileOrchestrationException)
{
throw new AIFileOrchestrationValidationException(
throw CreateAIFileOrchestrationValidationException(
nullAIFileOrchestrationException);
}
catch (InvalidAIFileOrchestrationException invalidAIFileOrchestrationException)
{
throw new AIFileOrchestrationValidationException(invalidAIFileOrchestrationException);
throw CreateAIFileOrchestrationValidationException(
invalidAIFileOrchestrationException);
}
catch (LocalFileValidationException localFileValidationException)
{
throw new AIFileOrchestrationDependencyValidationException(
throw CreateAIFileOrchestrationDependencyValidationException(
localFileValidationException.InnerException as Xeption);
}
catch (LocalFileDependencyValidationException localFileDependencyValidationException)
{
throw new AIFileOrchestrationDependencyValidationException(
throw CreateAIFileOrchestrationDependencyValidationException(
localFileDependencyValidationException.InnerException as Xeption);
}
catch (LocalFileDependencyException localFileDependencyException)
{
throw new AIFileOrchestrationDependencyException(
throw CreateAIFileOrchestrationDependencyException(
localFileDependencyException.InnerException as Xeption);
}
catch (LocalFileServiceException localFileServiceException)
{
throw new AIFileOrchestrationDependencyException(
throw CreateAIFileOrchestrationDependencyException(
localFileServiceException.InnerException as Xeption);
}
catch (AIFileValidationException aIFileValidationException)
{
throw new AIFileOrchestrationDependencyValidationException(
throw CreateAIFileOrchestrationDependencyValidationException(
aIFileValidationException.InnerException as Xeption);
}
catch (AIFileDependencyValidationException aIFileDependencyValidationException)
{
throw new AIFileOrchestrationDependencyValidationException(
throw CreateAIFileOrchestrationDependencyValidationException(
aIFileDependencyValidationException.InnerException as Xeption);
}
catch (AIFileDependencyException aIFileDependencyException)
{
throw new AIFileOrchestrationDependencyException(
throw CreateAIFileOrchestrationDependencyException(
aIFileDependencyException.InnerException as Xeption);
}
catch (AIFileServiceException aIFileServiceException)
{
throw new AIFileOrchestrationDependencyException(
throw CreateAIFileOrchestrationDependencyException(
aIFileServiceException.InnerException as Xeption);
}
catch (Exception exception)
{
var failedAIFileOrchestrationServiceException =
new FailedAIFileOrchestrationServiceException(
message: "Failed AI file service error occurred, contact support.",
exception);

throw new AIFileOrchestrationServiceException(
throw CreateAIFileOrchestrationServiceException(
failedAIFileOrchestrationServiceException);
}
}
Expand All @@ -92,28 +94,67 @@ private async ValueTask<IEnumerable<AIFileResponse>> TryCatch(ReturningAIFilesFu
}
catch (AIFileDependencyException aIFileDependencyException)
{
throw new AIFileOrchestrationDependencyException(
throw CreateAIFileOrchestrationDependencyException(
aIFileDependencyException.InnerException as Xeption);
}
catch (AIFileDependencyValidationException aIFileDependencyValidationException)
{
throw new AIFileOrchestrationDependencyValidationException(
throw CreateAIFileOrchestrationDependencyValidationException(
aIFileDependencyValidationException.InnerException as Xeption);
}
catch (AIFileServiceException aIFileServiceException)
{
throw new AIFileOrchestrationDependencyException(
throw CreateAIFileOrchestrationDependencyException(
aIFileServiceException.InnerException as Xeption);
}
catch (Exception exception)
{
var failedAIFileOrchestrationServiceException =
new FailedAIFileOrchestrationServiceException(
message: "Failed AI file service error occurred, contact support.",
exception);

throw new AIFileOrchestrationServiceException(
throw CreateAIFileOrchestrationServiceException(
failedAIFileOrchestrationServiceException);
}
}

private static AIFileOrchestrationValidationException CreateAIFileOrchestrationValidationException(
Xeption innerException)
{
return new AIFileOrchestrationValidationException(
message: "AI file validation error occurred, fix errors and try again.",
innerException);
}

private static AIFileOrchestrationDependencyValidationException
CreateAIFileOrchestrationDependencyValidationException(Xeption innerException)
{
return new AIFileOrchestrationDependencyValidationException(
message: "AI file dependency validation error occurred, fix errors and try again.",
innerException);
}

private static AIFileOrchestrationDependencyException CreateAIFileOrchestrationDependencyException(
Xeption innerException)
{
return new AIFileOrchestrationDependencyException(
message: "AI File dependency error occurred, contact support.",
innerException);
}

private static AIFileOrchestrationServiceException CreateAIFileOrchestrationServiceException(
Xeption innerException)
{
return new AIFileOrchestrationServiceException(
message: "AI File error occurred, contact support.",
innerException);
}

private static NullAIFileOrchestrationException CreateNullAIFileOrchestrationException()
{
return new NullAIFileOrchestrationException(
message: "AI file is null.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static void ValidateAIFileNotNull(AIFile aiFile)
{
if (aiFile is null)
{
throw new NullAIFileOrchestrationException();
throw CreateNullAIFileOrchestrationException();
}
}

Expand Down Expand Up @@ -53,7 +53,9 @@ private static void ValidateAIFileIdNotNull(string fileId)

private static void Validate(params (dynamic Rule, string Parameter)[] validations)
{
var invalidAIFileException = new InvalidAIFileOrchestrationException();
var invalidAIFileException =
new InvalidAIFileOrchestrationException(
message: "AI file is invalid.");

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

0 comments on commit 6fdccc8

Please sign in to comment.