{"record":{"id":"9506c91fdf88bd68","repo":"nopSolutions/nopCommerce","slug":"e-message","errorCode":null,"errorMessage":"{e.Message}","messagePattern":"\\{e\\.Message\\}","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/ArtificialIntelligence/ArtificialIntelligenceService.cs","lineNumber":211,"sourceCode":"                var metaDescriptionQueryFormat = string.IsNullOrEmpty(_artificialIntelligenceSettings.MetaDescriptionQuery)\n                    ? ArtificialIntelligenceDefaults.MetaDescriptionQuery\n                    : _artificialIntelligenceSettings.MetaDescriptionQuery;\n                var metaDescriptionQuery = string.Format(metaDescriptionQueryFormat, title, text, currentLanguage.Name);\n                var result = await _httpClient.SendQueryAsync(metaDescriptionQuery);\n                metaDescription = result.Trim('\"');\n            }\n            else\n            {\n                metaDescription = currentMetaDescription;\n            }\n\n        }\n        catch (Exception e)\n        {\n            var customer = await _workContext.GetCurrentCustomerAsync();\n            await _logger.ErrorAsync(e.Message, e, customer);\n\n            throw new NopException(e.Message);\n        }\n\n        return (metaTitle, metaKeywords, metaDescription);\n    }\n\n    /// <summary>\n    /// Create meta tags by artificial intelligence\n    /// </summary>\n    /// <param name=\"entity\">The entity to which need to generate meta tags</param>\n    /// <param name=\"currentMetaTitle\">Current entity meta title</param>\n    /// <param name=\"currentMetaKeywords\">Current entity meta keywords</param>\n    /// <param name=\"currentMetaDescription\">Current entity meta description</param>\n    /// <param name=\"languageId\">Target language identifier</param>\n    /// <returns>\n    /// A task that represents the asynchronous operation\n    /// The task result contains the generated meta tags\n    /// </returns>\n    protected virtual async Task<(string metaTitle, string metaKeywords, string metaDescription)> CreateMetaTagsAsync<TEntity>(TEntity entity,","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/ArtificialIntelligence/ArtificialIntelligenceService.cs#L193-L229","documentation":"In ArtificialIntelligenceService.CreateMetaTagsAsync, a try/catch wraps all AI calls (meta title, keywords, description generation). Any exception is logged via _logger.ErrorAsync then re-thrown as a new NopException(e.Message). This loses the original stack/inner detail (no innerException passed) but preserves the message text, so callers see the underlying AI error as a NopException.","triggerScenarios":"Generating meta tags for a Product/Category/BlogPost/Manufacturer/Topic/Vendor when any of the inner SendQueryAsync calls fail (provider error, timeout) — the catch re-wraps it as NopException(e.Message).","commonSituations":"AI provider misconfiguration or outage during meta-tag generation; RequestTimeout too short; missing title/text passed forward after validation; transient network error to the AI endpoint.","solutions":["Fix the underlying AI provider error (see SendQueryAsync NopException): verify API key, quota, network, RequestTimeout.","Catch NopException at the calling layer and degrade gracefully (keep existing meta tags) rather than failing the whole entity save.","Ensure the entity has non-empty title/text so ValidateTitleAndTextAsync does not throw before AI calls.","Check the log (the original exception is recorded with full detail) to find root cause."],"exampleFix":"// before\nvar (t, k, d) = await _aiService.CreateMetaTagsAsync(entity, languageId);\n\n// after\ntry\n{\n    var (t, k, d) = await _aiService.CreateMetaTagsAsync(entity, languageId);\n}\ncatch (NopException)\n{\n    // keep existing meta tags; AI generation is non-critical\n}","handlingStrategy":"try-catch","validationCode":"// Ensure entity has title/text in target language before calling meta generation\n// (delegates to ValidateTitleAndTextAsync which throws on empty)","typeGuard":null,"tryCatchPattern":"try { var (t,k,d) = await _aiService.CreateMetaTagsAsync(entity, languageId); }\ncatch (NopException) { /* keep existing meta tags; AI generation is non-critical */ }","preventionTips":["Treat meta-tag generation as non-blocking; catch NopException and keep existing values.","Ensure the entity has non-empty title/text so validation does not throw.","Check the log for the original exception detail (it is recorded with stack)."],"tags":["ai","meta-tags","error-wrapping","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}