close
Espacios de nombres
Variantes

std::system_error

De cppreference.com
 
 
Biblioteca de servicios
 
 
<tbody> </tbody>
Definido en el archivo de encabezado <system_error>
class system_error;
(desde C++11)
std::system_error es el tipo de la excepción lanzada por varias funciones de la biblioteca (por lo general las funciones que interactúan con las instalaciones del sistema operativo, por ejemplo, el constructor de std::thread), cuando la excepción se ha asociado a un std::error_code que debe ser reportado .
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.
Imagecpp/error/exceptioncpp/error/runtime error

Inheritance diagram

Las funciones miembro

Construye el objeto system_error.
(función miembro pública) [editar]
Devuelve el código de error.
(función miembro pública) [editar]
[virtual]
Devuelve una cadena aclaratoria.
(función miembro virtual pública) [editar]

Heredado de std::exception

Funciones miembro

[virtual]
Destruye el objeto excepción.
(función miembro virtual pública de std::exception) [editar]
[virtual]
Devuelve una cadena aclaratoria.
(función miembro virtual pública de std::exception) [editar]

Ejemplo

#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';
    }
}

Salida:

Caught system_error with code generic:22 meaning Invalid argument