1 /******************************************************************************* 2 * thrill/net/exception.hpp 3 * 4 * Part of Project Thrill - http://project-thrill.org 5 * 6 * Copyright (C) 2015 Timo Bingmann <tb@panthema.net> 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: Exception(const std::string & what)33 explicit Exception(const std::string& what) 34 : std::runtime_error(what) 35 { } 36 Exception(const std::string & what,int _errno)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 /******************************************************************************/ 51