private IError HandleException(IError error) { var buildError = error.Exception switch { Exception exception => HandleException(error, exception), _ => HandleException(error, error.Exception) }; if (!int.TryParse(buildError.Code, out int code) || code <= 499) { return(buildError); } error.SetExtension("TraceId", _httpContextAccessor?.HttpContext?.TraceIdentifier); error.SetExtension("RequestId", _httpContextAccessor?.HttpContext?.Request.Headers["CorrelationId"].ToString()); _logger.LogError(error.Exception, "{message}. Code: {code}. Path: {path}. GraphQLCode: {GraphQLCode}. ", error.Message, code, error.Path, error.Code); return(buildError); }