std::system_error:: system_error
From cppreference.net
<
cpp
|
error
|
system error
C++
Utilities library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diagnostics library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::system_error
| Member functions | ||||
|
system_error::system_error
|
||||
|
system_error
(
std::
error_code
ec
)
;
|
(1) | (C++11부터) |
|
system_error
(
std::
error_code
ec,
const
std::
string
&
what_arg
)
;
|
(2) | (C++11부터) |
|
system_error
(
std::
error_code
ec,
const
char
*
what_arg
)
;
|
(2) | (C++11부터) |
|
system_error
(
int
ev,
const
std::
error_category
&
ecat
)
;
|
(3) | (C++11부터) |
|
system_error
(
int
ev,
const
std::
error_category
&
ecat,
const std:: string & what_arg ) ; |
(4) | (C++11부터) |
|
system_error
(
int
ev,
const
std::
error_category
&
ecat,
const char * what_arg ) ; |
(4) | (C++11부터) |
|
system_error
(
const
system_error
&
other
)
noexcept
;
|
(5) | (C++11부터) |
새로운 시스템 오류 객체를 생성합니다.
1)
오류 코드
ec
로 생성합니다.
3)
기본 오류 코드
ev
와 연관된 오류 카테고리
ecat
를 사용하여 생성합니다.
4)
기본 오류 코드
ev
, 관련 오류 카테고리
ecat
및 설명 문자열
what_arg
으로 생성합니다.
what()
에 의해 반환되는 문자열은
what_arg
을 하위 문자열로 포함함이 보장됩니다(내장된 null 문자를 포함하지 않는다고 가정할 때).
5)
복사 생성자. 내용을
other
의 내용으로 초기화합니다.
*
this
와
other
모두가 동적 타입
std::system_error
를 가지고 있다면
std::
strcmp
(
what
(
)
, other.
what
(
)
)
==
0
입니다.
매개변수
| ec | - | 오류 코드 |
| ev | - | ecat 와 연관된 열거형의 기본 오류 코드 |
| ecat | - | 오류 카테고리 |
| what_arg | - | 설명 문자열 |
| other | - |
복사할 다른
system_error
|
예제
system_error
예외를
errno
값으로부터 생성하는 방법을 보여줍니다.
이 코드 실행
#include <iostream> #include <system_error> int main() { try { throw std::system_error(EDOM, std::generic_category(), "FIX ME"); } catch (const std::system_error& ex) { std::cout << "code: [" << ex.code() << "]\n" "message: [" << ex.code().message() << "]\n" "what: [" << ex.what() << "]\n"; } }
가능한 출력:
code: [generic:33] message: [Numerical argument out of domain] what: [FIX ME: Numerical argument out of domain]