No, your code is doing silly things like trying to gather statistics on partitions while it is creating partitions. It also appears to be doing a strange job of creating on the fly ddl commands and may have issues with how it handles error logging. But it's hard to tell if you are not willing to show it, which seems strange also since your original post asks about misleading error messages.
There's also a PL/SQL forum, they may have other suggestions.
Personally, I would see if doing manually what you are trying to do automatically has the same issues. From what I've seen so far, Oracle is telling you exactly what you are doing wrong.