fork download
  1. #include <iostream>
  2. #include <system_error>
  3.  
  4. int main()
  5. {
  6.  
  7. std::error_condition econd = std::system_category().default_error_condition(EFAULT);
  8. std::cout << "Category: " << econd.category().name() << '\n'
  9. << "Value: " << econd.value() << '\n'
  10. << "Message: " << econd.message() << '\n';
  11.  
  12. try
  13. {
  14. throw std::system_error( std::error_code(EFAULT, std::system_category()) );
  15. }
  16. catch (const std::system_error& error)
  17. {
  18. std::cout << "Error: " << error.code()
  19. << " - " << error.code().message()
  20. << ". Category: " << error.code().category().name()
  21. << '\n';
  22. }
  23. }
Success #stdin #stdout 0s 3064KB
stdin
Standard input is empty
stdout
Category: system
Value: 14
Message: Bad address
Error: system:14 - Bad address. Category: system