/// <summary> /// Add translated error record and log un-translated message /// </summary> /// <param name="result"></param> /// <param name="logger"></param> /// <param name="localizer"></param> /// <param name="errorKey">Error key found in culture files</param> /// <param name="resourceIdentifier"></param> /// <param name="errors">Additional errors to forward. These are assumed to have already been translated.</param> /// <param name="arguments">The values with which to format the translated error message</param> public static void AddErrorsAndLog <T>(this IResult <T> result, ILogger logger, IStringLocalizer localizer, string errorKey, long resourceIdentifier, IEnumerable <IError> errors = null, params object[] arguments) { var errorMessage = localizer[errorKey, arguments]; var logMessage = localizer.Default(errorKey, arguments); var methodName = new StackTrace().GetFrame(1).GetMethod().Name; result.AddErrorsAndLog <T>(logger, errorKey, errorMessage, logMessage, resourceIdentifier.ToString(), errors, methodName); }
/// <summary> /// Add translated error record and log un-translated message /// </summary> /// <param name="result"></param> /// <param name="logger"></param> /// <param name="localizer"></param> /// <param name="errorKey">Error key found in culture files</param> /// <param name="arguments">The values with which to format the translated error message</param> public static void AddErrorAndLog <T>(this IResult <T> result, ILogger logger, IStringLocalizer localizer, string errorKey, params object[] arguments) { var errorMessage = localizer[errorKey, arguments]; var logMessage = localizer.Default(errorKey, arguments); var methodName = new StackTrace().GetFrame(1).GetMethod().Name; result.AddErrorsAndLog <T>(logger, errorKey, errorMessage, logMessage, null, null, methodName); }