std::system_error
Da cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Definido no cabeçalho <system_error>
|
||
class system_error; |
(desde C++11) | |
std::system_error
é o tipo da exceção lançada por várias funções de biblioteca (normalmente as funções que fazem interface com as instalações do sistema operacional, por exemplo, o construtor de std::thread), quando a exceção tem um std::error_code associado, que terá de ser comunicado.Original:
std::system_error
is the type of the exception thrown by various library functions (typically the functions that interface with the OS facilities, e.g. the constructor of std::thread), when the exception has an associated std::error_code which needs to be reported.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Índice |
[editar] Funções de membro
constrói o objeto system_error Original: constructs the system_error objectThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
retorna código de erro Original: returns error code The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
[virtual] |
Retorna a string explicativo Original: returns explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública virtual membro) |
Herdado de std::exception
Member functions
[virtual] |
destrói o objeto de exceção Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::exception função pública virtual membro)
|
[virtual] |
retorna uma cadeia explicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::exception função pública virtual membro)
|
[editar] Exemplo
#include <thread> #include <iostream> #include <system_error> int main() { try { std::thread().detach(); // attempt to detach a non-thread } catch(const std::system_error& e) { std::cout << "Caught system_error with code " << e.code() << " meaning " << e.what() << '\n'; } }
Saída:
Caught system_error with code generic:22 meaning Invalid argument