std::system_error
cppreference.net에서
| 헤더에 정의됨 <system_error>
|
||
class system_error;
|
(C++11부터) | |
std::system_error 은(는) 다양한 라이브러리 함수(일반적으로 OS 기능과 인터페이스하는 함수, 예: std::thread의 생성자)가 예외와 연관된 std::error_code를 가질 때 던져지는 예외 유형이며, 이는 보고될 수 있습니다.
상속 다이어그램
멤버 함수
system_error
객체를 생성합니다
(public member function) |
|
system_error
객체를 대체합니다
(public member function) |
|
|
에러 코드를 반환합니다
(public member function) |
|
|
[virtual]
|
설명 문자열을 반환합니다
(virtual public member function) |
std:: exception 로부터 상속됨
멤버 함수
|
[virtual]
|
예외 객체를 파괴함
(
std::exception
의 virtual public 멤버 함수)
|
|
[virtual]
|
설명 문자열을 반환함
(
std::exception
의 virtual public 멤버 함수)
|
예제
이 코드 실행
#include <iostream> #include <system_error> #include <thread> 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"; } }
가능한 출력:
Caught system_error with code [generic:22] meaning [Invalid argument]