Fixed ZEN-11384

This seems like a lot of repeating the same isinstance if. Also msg is created in exactly the same way in the second two cases. Why not wrap all of this under a single if isinstance, and do startswith... or startswith.. and create that msg once?