LCOV - code coverage report
Current view: top level - dbe/src/internal - config_api.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 25 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 6 0

            Line data    Source code
       1              : /*
       2              :  * config_api.cpp
       3              :  *
       4              :  *  Created on: Nov 2, 2015
       5              :  *      Author: Leonidas Georgopoulos
       6              :  */
       7              : 
       8              : #include "dbe/Exceptions.hpp"
       9              : #include "dbe/version.hpp"
      10              : #include "dbe/config_api_version.hpp"
      11              : 
      12              : #include "conffwk/Errors.hpp"
      13              : #include "ers/Issue.hpp"
      14              : #include <algorithm>
      15              : #include <sstream>
      16              : #include <string>
      17              : 
      18              : char const * const dbe_lib_config_api_version = dbe_compiled_version;
      19              : 
      20              : //------------------------------------------------------------------------------------------
      21              : //                                      DBE::CONFIG::ERRORS NAMESPACE
      22              : //------------------------------------------------------------------------------------------
      23              : namespace dbe
      24              : {
      25              : namespace config
      26              : {
      27              : namespace errors
      28              : {
      29              : 
      30              : namespace
      31              : {
      32            0 : inline std::string const trendl ( std::string s )
      33              : {
      34            0 :   s.erase ( std::remove ( s.begin(), s.end(), '\n' ), s.end() );
      35            0 :   return s;
      36              : }
      37              : }
      38              : 
      39              : /**
      40              :  * Unwind all causes linked to this exception
      41              :  *
      42              :  * @param ex the exception to process
      43              :  * @return a string
      44              :  */
      45            0 : std::string const unwind ( ers::Issue const & exception )
      46              : {
      47              : 
      48            0 :   if ( ers::Issue const * cause = exception.cause() )
      49              :   {
      50            0 :     std::stringstream s;
      51              : 
      52            0 :     while ( cause != nullptr )
      53              :     {
      54            0 :       s << trendl ( cause->what() ) << "\n";
      55            0 :       cause = cause->cause();
      56              :     }
      57              : 
      58            0 :     return s.str();
      59            0 :   }
      60              :   else
      61              :   {
      62            0 :     return topcause ( exception );
      63              :   }
      64              : 
      65              : }
      66              : 
      67              : /**
      68              :  * Provide a string with the reason given by the exception
      69              :  *
      70              :  * @param ex is the exception to process
      71              :  * @return a string
      72              :  */
      73            0 : std::string const reason ( ers::Issue const & exception )
      74              : {
      75            0 :   return exception.what();
      76              : }
      77              : 
      78              : /**
      79              :  * Provide a string with the top level cause in this exception
      80              :  *
      81              :  * @param ex is the exception to process
      82              :  * @return a string
      83              :  */
      84            0 : std::string const topcause ( ers::Issue const & exception )
      85              : {
      86            0 :   if ( ers::Issue const * cause = exception.cause() )
      87              :   {
      88            0 :     return cause->what();
      89              :   }
      90              :   else
      91              :   {
      92            0 :     return exception.what();
      93              :   }
      94              : }
      95              : 
      96              : /**
      97              :  * Dump the exception caught at full detail level as specified by the environment
      98              :  * @param ex is the exception to process
      99              :  * @return a string
     100              :  */
     101            0 : std::string const dump ( ers::Issue const & exception )
     102              : {
     103            0 :   std::stringstream s;
     104            0 :   s << exception;
     105            0 :   return s.str();
     106            0 : }
     107              : 
     108            0 : std::string const parse ( ers::Issue const & exception )
     109              : {
     110            0 :   return unwind ( exception );
     111              : }
     112              : 
     113              : //------------------------------------------------------------------------------------------
     114              : }
     115              : }
     116              : }
     117              : //------------------------------------------------------------------------------------------
     118              : 
        

Generated by: LCOV version 2.0-1