{"record":{"id":"853fc052d5bf9c03","repo":"Tyrrrz/DiscordChatExporter","slug":"failed-to-export-message-message-id-in-channel","errorCode":null,"errorMessage":"Failed to export message #{message.Id} in channel '{request.Channel.Name}' (#{request.Channel.Id}) of guild '{request.Guild.Name} (#{request.Guild.Id})'.","messagePattern":"Failed to export message #(.+?) in channel '(.+?)' \\(#(.+?)\\) of guild '(.+?) \\(#(.+?)\\)'\\.","errorType":"exception","errorClass":"DiscordChatExporterException","httpStatus":null,"severity":"error","filePath":"DiscordChatExporter.Core/Exporting/ChannelExporter.cs","lineNumber":98,"sourceCode":"                cancellationToken\n            );\n\n        await foreach (var message in messages)\n        {\n            try\n            {\n                // Resolve members for referenced users\n                foreach (var user in message.GetReferencedUsers())\n                    await context.PopulateMemberAsync(user, cancellationToken);\n\n                // Export the message\n                if (request.MessageFilter.IsMatch(message))\n                    await messageExporter.ExportMessageAsync(message, cancellationToken);\n            }\n            catch (Exception ex)\n            {\n                // Provide more context to the exception, to simplify debugging based on error messages\n                throw new DiscordChatExporterException(\n                    $\"Failed to export message #{message.Id} \"\n                        + $\"in channel '{request.Channel.Name}' (#{request.Channel.Id}) \"\n                        + $\"of guild '{request.Guild.Name} (#{request.Guild.Id})'.\",\n                    ex is not DiscordChatExporterException dex || dex.IsFatal,\n                    ex\n                );\n            }\n        }\n    }\n}\n","sourceCodeStart":80,"sourceCodeEnd":109,"githubUrl":"https://github.com/Tyrrrz/DiscordChatExporter/blob/f6865c82167c3bfee4455da80a1f1ca5e71b95ad/DiscordChatExporter.Core/Exporting/ChannelExporter.cs#L80-L109","documentation":"Thrown as DiscordChatExporterException wrapping the original exception for a single message that failed during the export loop. The message includes channel name/id and guild name/id for context, and sets isFatal by inheriting it from a wrapped DiscordChatExporterException (true if the inner was fatal or was not a DiscordChatExporterException). The inner exception is preserved as InnerException for debugging.","triggerScenarios":"Inside the message enumeration loop, the try block at ChannelExporter.cs resolves referenced members and calls messageExporter.ExportMessageAsync; any thrown exception is caught and re-wrapped at ChannelExporter.cs:99 with the message/guild/channel context.","commonSituations":"A malformed attachment URL, transient HTTP failure downloading an asset, disk-full/write error, an unparseable embed, or a serialization failure on one message while the rest of the channel exports fine.","solutions":["Inspect ex.InnerException for the real cause — the outer message is only context.","For transient IO/network errors, retry the single channel export; assets are re-fetched on demand.","Ensure sufficient disk space and write permissions in the output/assets directory.","If a specific message consistently fails, narrow the --before/--after window to isolate or skip it, and report the inner stack trace upstream."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// No full prevention; reduce surface by ensuring disk space and asset reachability\nif (DriveInfo.GetDiskFreeSpace(outputDir) < 1L * 1024 * 1024 * 1024)\n    throw new InvalidOperationException(\"Insufficient disk space for export.\");","typeGuard":null,"tryCatchPattern":"try { await exporter.ExportChannelAsync(req, progress, ct); }\ncatch (DiscordChatExporterException ex) when (ex.Message.StartsWith(\"Failed to export message\"))\n{\n    logger.LogError(ex.InnerException, \"Message failed in {Channel}\", req.Channel.Name);\n    // optionally continue to next channel without aborting the batch\n}","preventionTips":["Inspect InnerException for the real cause; the outer message is only context.","Ensure disk space and write permissions before large exports.","Retry transient per-message IO/network failures on the same channel."],"tags":["export","per-message","wrapper","debugging"],"backgroundTag":null,"analyzedSha":"f6865c82167c3bfee4455da80a1f1ca5e71b95ad","analyzedAt":"2026-08-13T18:08:46.403Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}