How to avoid "Sorry, my bot code is having an issue" in Microsoft Bot Framework

You can use DefaultIfException functionality for Bot Framework to internally handle the exception.

It looks like this:

await Conversation.SendAsync(
   activity, () => new Dialogs.RootDialog().DefaultIfException()
);

The message is sent to the user in PostUnhandledExceptionToUserTask only because the exception has escaped the root dialog A. You can avoid this situation by preventing unhandled exceptions from escaping the root dialog A.

One option is to add a different root dialog B that simply calls your dialog A and then simply ignores the IAwaitable<R> result that is passed to the ResumeAfter<R> callback.

Chain.DefaultIfException provides an implementation of dialog B.