I have seen a couple of instances where one or two individual items cannot be deleted due to being in channels that no longer exist or are now hidden or something. It is better to just log that error for that one message unable to be deleted, and continue and process the rest.
This is by design - if the server can't delete something it's safer to exit than to continue and potentially spam bad requests. You can run the program again if it looks all fine.
I have seen a couple of instances where one or two individual items cannot be deleted due to being in channels that no longer exist or are now hidden or something. It is better to just log that error for that one message unable to be deleted, and continue and process the rest.