aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Search/API/Controllers
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-01-27 20:37:39 -0600
committerJP Dillingham <jp@dillingham.me>2025-01-27 20:37:39 -0600
commitbfda68c3aef85a9b98f346f683f75472a4f423b9 (patch)
treec46119b71ce726b8fb74daad1e2e4cb1ca8ebab4 /src/slskd/Search/API/Controllers
parent43abc568fecca208385db6a8c61c534dcc4b051a (diff)
downloadslskd-bfda68c3aef85a9b98f346f683f75472a4f423b9.tar.gz
improve logging
Diffstat (limited to 'src/slskd/Search/API/Controllers')
-rw-r--r--src/slskd/Search/API/Controllers/SearchesController.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/slskd/Search/API/Controllers/SearchesController.cs b/src/slskd/Search/API/Controllers/SearchesController.cs
index d6d96bbe..58e1fe37 100644
--- a/src/slskd/Search/API/Controllers/SearchesController.cs
+++ b/src/slskd/Search/API/Controllers/SearchesController.cs
@@ -24,6 +24,7 @@ namespace slskd.Search.API
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+ using Serilog;
using SearchQuery = Soulseek.SearchQuery;
using SearchScope = Soulseek.SearchScope;
@@ -50,6 +51,7 @@ namespace slskd.Search.API
private ISearchService Searches { get; }
private IOptionsSnapshot<Options> OptionsSnapshot { get; }
+ private ILogger Log { get; set; } = Serilog.Log.ForContext<SearchesController>();
/// <summary>
/// Performs a search for the specified <paramref name="request"/>.
@@ -83,12 +85,19 @@ namespace slskd.Search.API
}
catch (Exception ex) when (ex is ArgumentException || ex is Soulseek.DuplicateTokenException)
{
+ Log.Error(ex, "Failed to execute search {Search}: {Message}", request, ex.Message);
return BadRequest(ex.Message);
}
catch (InvalidOperationException ex)
{
+ Log.Error(ex, "Failed to execute search {Search}: {Message}", request, ex.Message);
return Conflict(ex.Message);
}
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to execute search {Search}: {Message}", request, ex.Message);
+ return StatusCode(500, ex.Message);
+ }
return Ok(search);
}