Skip to content

Commit

Permalink
feat: Improve error handling in audio service
Browse files Browse the repository at this point in the history
  • Loading branch information
angelobreuer committed Mar 11, 2024
1 parent f03a45b commit 0ebb55b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Lavalink4NET/AudioServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ private async ValueTask RunAsync(CancellationToken cancellationToken = default)
var clientInformation = await clientTask.ConfigureAwait(false);
await RunInternalAsync(clientInformation, cancellationToken).ConfigureAwait(false);
}
catch (Exception exception)
{
_logger.AudioServiceError(exception);
throw;
}
finally
{
_logger.AudioServiceStopped();
Expand Down Expand Up @@ -337,4 +342,7 @@ internal static partial class Logging

[LoggerMessage(6, LogLevel.Information, "Audio Service is ready ({Duration}ms).", EventName = nameof(AudioServiceIsReady))]
public static partial void AudioServiceIsReady(this ILogger<AudioServiceBase> logger, long duration);

[LoggerMessage(7, LogLevel.Error, "The audio Service entered a failure state.", EventName = nameof(AudioServiceError))]
public static partial void AudioServiceError(this ILogger<AudioServiceBase> logger, Exception exception);
}
1 change: 1 addition & 0 deletions src/Lavalink4NET/LavalinkNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ public async ValueTask RunAsync(ClientInformation clientInformation, Cancellatio
catch (Exception exception)
{
_readyTaskCompletionSource.TrySetException(exception);
_logger.LogError(exception, "An exception occurred while running the Lavalink node.");
throw;
}
finally
Expand Down

0 comments on commit 0ebb55b

Please sign in to comment.