mirror of
https://github.com/2dust/v2rayN.git
synced 2026-08-17 12:42:07 +03:00
Log with caller (#9976)
This commit is contained in:
@@ -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<TOutput> HandleSafe<TInput, TOutput>(
|
||||
this Interaction<TInput, TOutput> 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<TInput, TOutput> 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user