Thrill  0.1
system_exception.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * thrill/common/system_exception.hpp
3  *
4  * Part of Project Thrill - http://project-thrill.org
5  *
6  * Copyright (C) 2015 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the BSD-2 license in the LICENSE file.
9  ******************************************************************************/
10 
11 #pragma once
12 #ifndef THRILL_COMMON_SYSTEM_EXCEPTION_HEADER
13 #define THRILL_COMMON_SYSTEM_EXCEPTION_HEADER
14 
15 #include <cerrno>
16 #include <cstring>
17 #include <stdexcept>
18 #include <string>
19 
20 namespace thrill {
21 namespace common {
22 
23 /*!
24  * An Exception which is thrown on system errors.
25  */
26 class SystemException : public std::runtime_error
27 {
28 public:
29  explicit SystemException(const std::string& what)
30  : std::runtime_error(what) { }
31 };
32 
33 /*!
34  * An Exception which is thrown on system errors and contains errno information.
35  */
37 {
38 public:
39  ErrnoException(const std::string& what, int _errno)
41  what + ": [" + std::to_string(_errno) + "] " + strerror(_errno))
42  { }
43 
44  explicit ErrnoException(const std::string& what)
45  : ErrnoException(what, -1) { }
46 };
47 
48 } // namespace common
49 } // namespace thrill
50 
51 #endif // !THRILL_COMMON_SYSTEM_EXCEPTION_HEADER
52 
53 /******************************************************************************/
ErrnoException(const std::string &what)
An Exception which is thrown on system errors.
An Exception which is thrown on system errors and contains errno information.
STL namespace.
ErrnoException(const std::string &what, int _errno)
static by_string to_string(int val)
convert to string
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220
SystemException(const std::string &what)