From 5cdb00c832d2cf82fecb7a6d75b59477c7504128 Mon Sep 17 00:00:00 2001 From: "jaloliddin.mahkamov@mail.ru" Date: Sat, 25 May 2024 00:32:27 +0500 Subject: [PATCH] ShouldThrowCriticalDependencyExceptionOnAddIfSqlErrorOccursAndLogItAsync->PASS --- .../VideoMetadataService.Exceptions.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/UsefulTime.Api/Services/Foundations/VedioMetadatas/VideoMetadataService.Exceptions.cs b/UsefulTime.Api/Services/Foundations/VedioMetadatas/VideoMetadataService.Exceptions.cs index a96763e..991b5e5 100644 --- a/UsefulTime.Api/Services/Foundations/VedioMetadatas/VideoMetadataService.Exceptions.cs +++ b/UsefulTime.Api/Services/Foundations/VedioMetadatas/VideoMetadataService.Exceptions.cs @@ -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; @@ -25,7 +26,26 @@ private async ValueTask 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 =