Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:39

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file corecel/io/ExceptionOutput.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <exception>
0010 #include <memory>
0011 #include <string>
0012 
0013 #include "corecel/sys/TypeDemangler.hh"
0014 
0015 #include "OutputInterface.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Save an exception to the 'result' for diagnostic output.
0022  *
0023  * \code
0024     try
0025     {
0026         ...
0027     }
0028     catch (...)
0029     {
0030         output_mgr.insert(std::make_shared<ExceptionOutput>(
0031             std::current_exception()));
0032     }
0033    \endcode
0034  */
0035 class ExceptionOutput final : public OutputInterface
0036 {
0037   public:
0038     // Construct with an exception pointer
0039     explicit ExceptionOutput(std::exception_ptr e);
0040 
0041     // Protected destructor
0042     ~ExceptionOutput();
0043 
0044     // Category of data to write
0045     Category category() const final { return Category::result; }
0046 
0047     // Key for the entry inside the category.
0048     std::string_view label() const final { return "exception"; }
0049 
0050     // Write output to the given JSON object
0051     void output(JsonPimpl*) const final;
0052 
0053   private:
0054     std::unique_ptr<JsonPimpl> output_;
0055 };
0056 
0057 //---------------------------------------------------------------------------//
0058 }  // namespace celeritas