Refactor error constants/messages in metadata module