CallingBotSample.Utility.CommonUtils.ForgetAndLogExceptionAsync C# (CSharp) Method

ForgetAndLogExceptionAsync() public static method

public static ForgetAndLogExceptionAsync ( Task task, IGraphLogger logger, string description = null, string memberName = null, string filePath = null, int lineNumber ) : Task
task Task
logger IGraphLogger
description string
memberName string
filePath string
lineNumber int
return Task
        public static async Task ForgetAndLogExceptionAsync(
            this Task task,
            IGraphLogger logger,
            string description = null,
            [CallerMemberName] string memberName = null,
            [CallerFilePath] string filePath = null,
            [CallerLineNumber] int lineNumber = 0)
        {
            try
            {
                await task.ConfigureAwait(false);
                logger?.Verbose(
                    $"Completed running task successfully: {description ?? string.Empty}",
                    memberName: memberName,
                    filePath: filePath,
                    lineNumber: lineNumber);
            }
            catch (Exception e)
            {
                // Log and absorb all exceptions here.
                logger?.Error(
                    e,
                    $"Caught an Exception running the task: {description ?? string.Empty}",
                    memberName: memberName,
                    filePath: filePath,
                    lineNumber: lineNumber);
            }
        }
    }