parent
06b68772bd
commit
ee425ff8e0
@ -1,21 +0,0 @@
|
||||
namespace Recyclarr.Common.Extensions;
|
||||
|
||||
public static class ExceptionExtensions
|
||||
{
|
||||
public static string FullMessage(this Exception ex)
|
||||
{
|
||||
if (ex is AggregateException aex)
|
||||
{
|
||||
return aex.InnerExceptions.Aggregate("[ ", (total, next) => $"{total}[{next.FullMessage()}] ") + "]";
|
||||
}
|
||||
|
||||
var msg = ex.Message.Replace(", see inner exception.", "").Trim();
|
||||
var innerMsg = ex.InnerException?.FullMessage();
|
||||
if (innerMsg != null && !innerMsg.ContainsIgnoreCase(msg) && !msg.ContainsIgnoreCase(innerMsg))
|
||||
{
|
||||
msg = $"{msg} [ {innerMsg} ]";
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Flurl;
|
||||
using Recyclarr.Common.Extensions;
|
||||
|
||||
namespace Recyclarr.Http;
|
||||
|
||||
public static partial class Sanitize
|
||||
{
|
||||
public static string Message(string message)
|
||||
{
|
||||
// Replace full URLs
|
||||
var result = UrlRegex().Replace(message, SanitizeMatch);
|
||||
|
||||
// There are sometimes parenthetical parts of the message that contain the host but are not
|
||||
// detected as true URLs. Just strip those out completely.
|
||||
return HostRegex().Replace(result, "");
|
||||
}
|
||||
|
||||
public static string ExceptionMessage(Exception exception)
|
||||
{
|
||||
return Message(exception.FullMessage());
|
||||
}
|
||||
|
||||
public static Url Url(Url url)
|
||||
{
|
||||
// Replace hostname for user privacy
|
||||
url.Host = "REDACTED";
|
||||
return url;
|
||||
}
|
||||
|
||||
private static string SanitizeMatch(Match match)
|
||||
{
|
||||
return Url(match.Value).ToString() ?? match.Value;
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"\([-a-zA-Z0-9@:%._+~#=]{1,256}(?::[0-9]+)?\)")]
|
||||
private static partial Regex HostRegex();
|
||||
|
||||
[GeneratedRegex(@"https?://(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}(:[0-9]+)?\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)")]
|
||||
private static partial Regex UrlRegex();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace Recyclarr.Platform;
|
||||
|
||||
public static class LogProperty
|
||||
{
|
||||
public static string Scope => nameof(Scope);
|
||||
}
|
Loading…
Reference in new issue