Exception is thrown when error info is returned for a successful call (that also includes expected response data)
I'm not sure what the intended design is, but here's the scenario:
- Call subreddit.LinkPost(whatever).Submit();
- Throws Reddit.Exceptions.RedditAlreadySubmittedException
- Logic decides that we can resubmit
- Call subreddit.LinkPost(whatever).Submit(resubmit: true)
- Post is successfully created on subreddit
- But we now throw Reddit.Exceptions.RedditControllerException
It appears that even if a call is successful: no non-success status code, and we get back the expected data, the above exception will be thrown if there are any errors at all on the response payload, even when those errors may be expected.
Is there an elegant way to handle this? or Do I need to catch RedditControllerException?

Here are the two responses. The first one results in a specific exception we can catch and decide to repost or not. The second one seemingly just informs us that we have resubmitted an existing link, even though it did not result in an actual error.
Hmm yeah this is a definite issue. I was not aware that there were actually cases where the Reddit API will return error data in a successful response. I managed to find this post with some background info:
https://www.reddit.com/r/redditdev/comments/ezz3td/upcoming_api_change_post_apisubmit/fgqihwr/?context=3
I think the best solution here would be to make it so that Reddit.NET only throws the exception when errors are present AND there's no data. The only reason that logic isn't already there is because I didn't know that 'data' and 'errors' ever appeared together like this. Instead, I'll have it throw a newly-created WarningException so they can be easily caught and ignored.
I'll implement that change and it'll be included in the 1.6 release. In the meantime, my recommendation would be to catch the exception and check the data/errors to determine whether to ignore or rethrow it.
That sounds perfect thanks much! In the meantime I'll catch the controller exception per your suggestion
Actually it looks like the exception is thrown before the variable is assigned when we're creating a linkpost (which makes sense). In this case, we're trying to first create a linkpost and then create the first reply on that post (though we might be doing something else like assigning flair etc), a la:
var subreddit = reddit.Subreddit(subReddit);
var post = subreddit.LinkPost(postTitle, postUrl).Submit(resubmit: allowResubmit, flairId: flairId, flairText: flairText);
var comment = post.Reply(replyBody);
So we'd need to be able to hang on to "post", which is never assigned (though the post is made on reddit). I'll clone the repo and maybe hack something together to ignore this particular response for now since this client has a super narrow use case for allowing resubmit on link posts. Then will move back @ v1.6
A simpler approach would be to just bypass the controllers entirely by calling the model directly. You should be able to do that with the vanilla codebase still.
On Wed, Apr 14, 2021, 2:43 PM JohnnyPrimus @.***> wrote:
Actually it looks like the exception is thrown before the variable is assigned when we're creating a linkpost (which makes sense). In this case, we're trying to first create a linkpost and then create the first reply on that post (though we might be doing something else like assigning flair etc), a la:
var subreddit = reddit.Subreddit(subReddit); var post = subreddit.LinkPost(postTitle, postUrl).Submit(resubmit: allowResubmit, flairId: flairId, flairText: flairText); var comment = post.Reply(replyBody);
So we'd need to be able to hang on to "post", which is never assigned (though the post is made on reddit). I'll clone the repo and maybe hack something together to ignore this particular response for now since this client has a super narrow use case for allowing resubmit on link posts. Then will move back @ v1.6
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/sirkris/Reddit.NET/issues/133#issuecomment-819868194, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFTJZP2BU5I43ITAEPIZELTIYEBNANCNFSM426DW3OQ .