@@ -44,7 +44,7 @@ public async Task SendAutoUpdateResult(
4444 var result = await TrySendNotification ( message ) ;
4545
4646 if ( ! result )
47- logger . LogError (
47+ logger . LogWarning (
4848 "Failed to send auto-update notification for container {ContainerName}" ,
4949 container . Name
5050 ) ;
@@ -61,7 +61,11 @@ List<AppVersion> newerVersions
6161 return await TrySendNotification ( message ) ;
6262 }
6363
64- public async Task < bool > TrySendNotification ( string message , bool propagateExceptions = false )
64+ public async Task < bool > TrySendNotification (
65+ string message ,
66+ bool propagateExceptions = false ,
67+ bool noSuccessIsError = false
68+ )
6569 {
6670 var success = 0 ;
6771 if ( discordService . IsInitialized )
@@ -97,21 +101,18 @@ public async Task<bool> TrySendNotification(string message, bool propagateExcept
97101 if ( success != 0 )
98102 return true ;
99103
100- if ( ! AnyInitialized )
101- logger . LogWarning ( "No notification services are initialized. Message was not sent." ) ;
102- else
103- logger . LogError ( "The notification could not be sent successfully." ) ;
104+ var errorMessage = ! AnyInitialized
105+ ? "No notification services are initialized. Message was not sent."
106+ : "The notification could not be sent successfully." ;
104107
105- return false ;
106- }
108+ if ( noSuccessIsError )
109+ throw new ( errorMessage ) ;
107110
108- public async Task SendNotification ( string message )
109- {
110- var result = await TrySendNotification ( message , true ) ;
111+ logger . LogWarning ( errorMessage ) ;
111112
112- if ( ! result )
113- throw new Exception (
114- "No notification services have been initialized. Check logs for details."
115- ) ;
113+ return false ;
116114 }
115+
116+ public async Task SendNotification ( string message ) =>
117+ await TrySendNotification ( message , true , true ) ;
117118}
0 commit comments