Empty Name Error Class
Empty Name Error Class
Create your own exception type EmptyNameError that inherits publicly from std::exception (header <exception>) and overrides what() to return the text Player name cannot be empty. The override must have exactly the base signature, const char* what() const noexcept override. Then write registerPlayer(const std::string& name): when name is empty it throws an EmptyNameError; otherwise it prints Registered followed by the name.
Because your class derives from std::exception, a handler for const std::exception& catches it too: the first test catches EmptyNameError by name, the second catches it through the base class; both print Error: and the message.
Do NOT write a main function.
Expected Output:
Registered Ana Error: Player name cannot be empty Registered Bo
= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...