fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <stdexcept>
  4.  
  5. void getMusic(const std::string & key) {
  6. if(key.compare("") == 0) throw std::invalid_argument("empty key");
  7. }
  8.  
  9. int main() {
  10. try {
  11. getMusic("");
  12. } catch (const std::runtime_error &ob) {
  13. std::cout << ob.what() << std::endl;
  14. } catch (const std::invalid_argument &ob) {
  15. std::cout << ob.what() << std::endl;
  16. } catch (...) {
  17. std::cout << "unknown error\n";
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
empty key