Duplicate category codes explain themselves
Creating a non-academic category with a code already in use failed with a bare "internal error". You now get a message that quotes the code and says which category holds it (an archived one, or one in another academic session), so you know whether to restore that category or pick a different code.