-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ShouldThrowValidationExceptionIfFlexiMessageIsNull -> PASS
- Loading branch information
1 parent
e1a5ad0
commit 59218cd
Showing
10 changed files
with
115 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// --------------------------------------- | ||
// Copyright (c) 2024 Mabrouk Mahdhi. | ||
// Made with love for the .NET Community | ||
// --------------------------------------- | ||
|
||
using System.Threading.Tasks; | ||
using FlexiMail.Models.Foundations.Messages.Exceptions; | ||
using Xeptions; | ||
|
||
namespace FlexiMail.Services | ||
{ | ||
internal partial class FlexiExchangeService | ||
{ | ||
private delegate ValueTask SendFunction(); | ||
|
||
private static async ValueTask TryCatch(SendFunction sendFunction) | ||
{ | ||
try | ||
{ | ||
await sendFunction(); | ||
} | ||
catch (NullFlexiMessageException nullFlexiMessageException) | ||
{ | ||
throw CreateValidationException(nullFlexiMessageException); | ||
} | ||
} | ||
|
||
private static FlexiMessageValidationException CreateValidationException(Xeption exception) | ||
{ | ||
return new FlexiMessageValidationException( | ||
message: "Flexi Message validation error occurred, fix errors and try again.", | ||
innerException: exception); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// --------------------------------------- | ||
// Copyright (c) 2024 Mabrouk Mahdhi. | ||
// Made with love for the .NET Community | ||
// --------------------------------------- | ||
|
||
using FlexiMail.Models.Foundations.Messages; | ||
using FlexiMail.Models.Foundations.Messages.Exceptions; | ||
|
||
namespace FlexiMail.Services | ||
{ | ||
internal partial class FlexiExchangeService | ||
{ | ||
private static void ValidFlexiMessage(FlexiMessage flexiMessage) | ||
{ | ||
ValidFlexiMessageIsNotNull(flexiMessage); | ||
} | ||
|
||
private static void ValidFlexiMessageIsNotNull(FlexiMessage flexiMessage) | ||
{ | ||
if (flexiMessage == null) | ||
throw new NullFlexiMessageException(message: "FlexiMessage is null."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters