|
||||
File indexing completed on 2025-01-18 09:54:48
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file corecel/io/LogContextException.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <exception> 0011 0012 namespace celeritas 0013 { 0014 class OutputRegistry; 0015 0016 //---------------------------------------------------------------------------// 0017 /*! 0018 * Log an exception's context and optionally save to an output registry. 0019 * 0020 * Example: 0021 * \code 0022 CELER_TRY_HANDLE(step(), LogContextException{this->output_reg().get()}); 0023 \endcode 0024 */ 0025 struct LogContextException 0026 { 0027 void operator()(std::exception_ptr p); 0028 0029 OutputRegistry* out{nullptr}; 0030 }; 0031 0032 //---------------------------------------------------------------------------// 0033 /*! 0034 * Log any RichContextException and rethrow the embedded pointer. 0035 * 0036 * This is useful for unit tests and other situations where the nearest `catch` 0037 * does not use `std::rethrow_if_nested`. 0038 * 0039 * \code 0040 CELER_TRY_HANDLE(step(), log_context_exception); 0041 \endcode 0042 */ 0043 inline void log_context_exception(std::exception_ptr p) 0044 { 0045 return LogContextException{}(p); 0046 } 0047 0048 //---------------------------------------------------------------------------// 0049 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |