diff --git a/v2rayN/ServiceLib/Common/Extension.cs b/v2rayN/ServiceLib/Common/Extension.cs index a7e705db..d68d5403 100644 --- a/v2rayN/ServiceLib/Common/Extension.cs +++ b/v2rayN/ServiceLib/Common/Extension.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; namespace ServiceLib.Common; @@ -138,7 +139,10 @@ public static class Extension public static async Task HandleSafe( this Interaction interaction, TInput input, - TOutput defaultValue = default!) + TOutput defaultValue = default!, + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0) { try { @@ -146,12 +150,14 @@ public static class Extension } catch (UnhandledInteractionException ex) { - Logging.SaveLog($"Unhandled interaction exception for input: {input}", ex); + var title = $"Unhandled interaction exception in {memberName} at {filePath}:{lineNumber}"; + Logging.SaveLog(title, ex); return defaultValue; } catch (Exception ex) { - Logging.SaveLog($"Exception occurred while handling interaction for input: {input}", ex); + var title = $"Exception occurred while handling interaction in {memberName} at {filePath}:{lineNumber}, input: {input}"; + Logging.SaveLog(title, ex); return defaultValue; } }