Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:09

0001 /**
0002  * Copyright (c) 2017-present, Facebook, Inc.
0003  * All rights reserved.
0004  *
0005  * This source code is licensed under the BSD-style license found in the
0006  * LICENSE file in the root directory of this source tree.
0007  */
0008 
0009 #pragma once
0010 
0011 #include <chrono>
0012 #include <exception>
0013 
0014 #include "gloo/common/string.h"
0015 
0016 #define GLOO_ERROR_MSG(...) \
0017   ::gloo::MakeString("[", __FILE__, ":", __LINE__, "] ", __VA_ARGS__)
0018 
0019 namespace gloo {
0020 
0021 const std::chrono::milliseconds kNoTimeout = std::chrono::milliseconds::zero();
0022 
0023 // A base class for all gloo runtime errors
0024 struct Exception : public std::runtime_error {
0025   Exception() = delete;
0026   explicit Exception(const std::string& msg) : std::runtime_error(msg) {}
0027 };
0028 
0029 #define GLOO_THROW(...) \
0030   throw ::gloo::Exception(GLOO_ERROR_MSG(__VA_ARGS__))
0031 
0032 
0033 // Thrown for invalid operations on gloo APIs
0034 struct InvalidOperationException : public ::gloo::Exception {
0035   InvalidOperationException() = delete;
0036   explicit InvalidOperationException(const std::string& msg)
0037       : ::gloo::Exception(msg) {}
0038 };
0039 
0040 #define GLOO_THROW_INVALID_OPERATION_EXCEPTION(...) \
0041   throw ::gloo::InvalidOperationException(GLOO_ERROR_MSG(__VA_ARGS__))
0042 
0043 
0044 // Thrown for unrecoverable IO errors
0045 struct IoException : public ::gloo::Exception {
0046   IoException() = delete;
0047   explicit IoException(const std::string& msg) : ::gloo::Exception(msg) {}
0048 };
0049 
0050 #define GLOO_THROW_IO_EXCEPTION(...) \
0051   throw ::gloo::IoException(GLOO_ERROR_MSG(__VA_ARGS__))
0052 
0053 } // namespace gloo