[backend/core] Improve logging

This commit is contained in:
Laura Hausmann 2024-06-22 01:17:40 +02:00
parent 07f0223c99
commit f724a55901
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 5 additions and 4 deletions

View file

@ -70,14 +70,15 @@ public class WebFingerService(
var split = query.Split('@'); var split = query.Split('@');
domain = split.Length switch domain = split.Length switch
{ {
< 2 or > 3 => throw new GracefulException(HttpStatusCode.BadRequest, "Invalid query"), < 2 or > 3 => throw new GracefulException(HttpStatusCode.BadRequest, $"Invalid query: {query}"),
2 => throw new GracefulException(HttpStatusCode.BadRequest, "Can't run WebFinger for local user"), 2 => throw new GracefulException(HttpStatusCode.BadRequest,
$"Can't run WebFinger for local user: {query}"),
_ => split[2] _ => split[2]
}; };
} }
else else
{ {
throw new GracefulException(HttpStatusCode.BadRequest, "Invalid query"); throw new GracefulException(HttpStatusCode.BadRequest, $"Invalid query: {query}");
} }
return (query, proto, domain); return (query, proto, domain);

View file

@ -49,7 +49,7 @@ public class UserService(
private (string Username, string? Host) AcctToTuple(string acct) private (string Username, string? Host) AcctToTuple(string acct)
{ {
if (!acct.StartsWith("acct:")) throw new GracefulException(HttpStatusCode.BadRequest, "Invalid query"); if (!acct.StartsWith("acct:")) throw new GracefulException(HttpStatusCode.BadRequest, $"Invalid query: {acct}");
var split = acct[5..].Split('@'); var split = acct[5..].Split('@');
if (split.Length != 2) if (split.Length != 2)