File: system_error.cpp

package info (click to toggle)
yrmcds 1.0.4-6
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 924 kB
  • ctags: 1,346
  • sloc: cpp: 9,634; sh: 133; makefile: 97
file content (20 lines) | stat: -rw-r--r-- 568 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <system_error>
#include <cerrno>
#include <sys/types.h>
#include <fcntl.h>
#include <exception>
#include <iostream>

int main(int argc, char** argv) {
    open("/hoge/fuga/faaa", O_WRONLY|O_CREAT, 0700);
    try {
        throw std::system_error(errno, std::system_category(), "open");
    } catch( const std::exception& e ) {
        std::cout << e.what() << std::endl;
    }

    auto ec = std::system_category().default_error_condition(3);
    std::cout << "value=" << ec.value() << ", message=" << ec.message()
              << std::endl;
    return 0;
}