From 47a163e982bba60916d6ccb6ab186dcbe478749b Mon Sep 17 00:00:00 2001 From: primetime43 <12754111+primetime43@users.noreply.github.com> Date: Mon, 18 May 2026 20:09:53 -0400 Subject: [PATCH] Handle non-fatal exceptions in delete command Import DiscordChatExporter.Core.Exceptions and switch from a generic catch to catching DiscordChatExporterException only when it's non-fatal (catch (DiscordChatExporterException ex) when (!ex.IsFatal)). This ensures fatal exceptions propagate while non-fatal errors are counted and reported. Also clarified the channel option description by removing the incorrect 'in DMs' note about deletions. --- DiscordChatExporter.Cli/Commands/DeleteMessagesCommand.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DiscordChatExporter.Cli/Commands/DeleteMessagesCommand.cs b/DiscordChatExporter.Cli/Commands/DeleteMessagesCommand.cs index 797b2135..9b6221e3 100644 --- a/DiscordChatExporter.Cli/Commands/DeleteMessagesCommand.cs +++ b/DiscordChatExporter.Cli/Commands/DeleteMessagesCommand.cs @@ -5,6 +5,7 @@ using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Core.Discord; +using DiscordChatExporter.Core.Exceptions; using PowerKit.Extensions; namespace DiscordChatExporter.Cli.Commands; @@ -15,7 +16,7 @@ public partial class DeleteMessagesCommand : DiscordCommandBase [CommandOption( "channel", 'c', - Description = "Channel ID. Note: You can only delete your own messages in DMs." + Description = "Channel ID. Note: You can only delete your own messages." )] public required Snowflake ChannelId { get; set; } @@ -137,7 +138,7 @@ public partial class DeleteMessagesCommand : DiscordCommandBase // Discord's rate limit headers are handled automatically by DeleteMessageAsync } - catch + catch (DiscordChatExporterException ex) when (!ex.IsFatal) { failedCount++; using (console.WithForegroundColor(ConsoleColor.Red))