1 // Copyright (c) Facebook, Inc. and its affiliates. 2 // All rights reserved. 3 // 4 // This source code is licensed under the BSD-style license found in the 5 // LICENSE file in the root directory of this source tree. 6 7 #pragma once 8 9 #include <stdexcept> 10 11 #include <c10/macros/Macros.h> 12 #include <c10/util/Exception.h> 13 14 // Utility macro similar to C10_THROW_ERROR, the major difference is that this 15 // macro handles exception types defined in the c10d namespace, whereas 16 // C10_THROW_ERROR requires an exception to be defined in the c10 namespace. 17 #define C10D_THROW_ERROR(err_type, msg) \ 18 throw ::c10d::err_type( \ 19 {__func__, __FILE__, static_cast<uint32_t>(__LINE__)}, msg) 20 21 namespace c10d { 22 23 using c10::DistNetworkError; 24 25 class TORCH_API SocketError : public DistNetworkError { 26 using DistNetworkError::DistNetworkError; 27 }; 28 29 class TORCH_API TimeoutError : public DistNetworkError { 30 using DistNetworkError::DistNetworkError; 31 }; 32 33 } // namespace c10d 34