Thrill  0.1
exception.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * thrill/net/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_NET_EXCEPTION_HEADER
13 #define THRILL_NET_EXCEPTION_HEADER
14 
15 #include <cstring>
16 #include <stdexcept>
17 #include <string>
18 
19 namespace thrill {
20 namespace net {
21 
22 //! \addtogroup net_layer
23 //! \{
24 
25 /*!
26  * A Exception is thrown by Connection on all errors instead of returning
27  * error codes. If ever we manage to recover from network errors, we probably
28  * have to rebuild most of the network objects anyway.
29  */
30 class Exception : public std::runtime_error
31 {
32 public:
33  explicit Exception(const std::string& what)
34  : std::runtime_error(what)
35  { }
36 
37  Exception(const std::string& what, int _errno)
38  : std::runtime_error(
39  what + ": [" + std::to_string(_errno) + "] " + strerror(_errno))
40  { }
41 };
42 
43 // \}
44 
45 } // namespace net
46 } // namespace thrill
47 
48 #endif // !THRILL_NET_EXCEPTION_HEADER
49 
50 /******************************************************************************/
Exception(const std::string &what, int _errno)
Definition: exception.hpp:37
Exception(const std::string &what)
Definition: exception.hpp:33
STL namespace.
static by_string to_string(int val)
convert to string
A Exception is thrown by Connection on all errors instead of returning error codes.
Definition: exception.hpp:30
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220