Skip to content

Commit

Permalink
ShouldThrowCriticalDependencyExceptionOnAddIfSqlErrorOccursAndLogItAs…
Browse files Browse the repository at this point in the history
…ync->PASS
  • Loading branch information
JaloliddinDeveloper committed May 24, 2024
1 parent 1285d98 commit 5cdb00c
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//Copyright (c) Coalition of Good-Hearted Engineers
//Free To Use To Find Comfort and Pease
//=================================================
using Microsoft.Data.SqlClient;
using UsefulTime.Api.Models.VideoMetadatas;
using UsefulTime.Api.Models.VideoMetadatas.Exceptions;
using Xeptions;
Expand All @@ -25,7 +26,26 @@ private async ValueTask<VideoMetadata> TryCatch(ReturningVideoMetadataFunction r
{
throw CreateAndLogValidationException(invalidVideoMetadataException);
}
catch (SqlException sqlException )
{
var failedVideoMetadataStorageException =
new FailedVideoMetadataStorageException(
message: "Failed video metadata error occured, cotact support",
innerException: sqlException);
throw CreateAndLogCriticalDependencyException(failedVideoMetadataStorageException);
}
}

private VideoMetadataDependencyException CreateAndLogCriticalDependencyException(Xeption exception)
{
var videoMetadataDependencyException =
new VideoMetadataDependencyException(
message: "Video metadata error occured, fix the errors and try again",
innerException: exception);
this.loggingBroker.LogCritical(videoMetadataDependencyException);
throw videoMetadataDependencyException;
}

private VideoMetadataValidationException CreateAndLogValidationException(Xeption exception)
{
var videoMetadataValidationException =
Expand Down

0 comments on commit 5cdb00c

Please sign in to comment.