Return error and exception if class is already declared (closes #4093)