LCOV - code coverage report
Current view: top level - src/Tools/Exception - exception.cpp (source / functions) Hit Total Coverage
Test: streampu_clean.info Lines: 6 19 31.6 %
Date: 2024-07-31 15:48:41 Functions: 1 4 25.0 %

          Line data    Source code
       1             : #include <utility>
       2             : 
       3             : #include "Tools/Exception/exception.hpp"
       4             : #include "Tools/system_functions.h"
       5             : 
       6             : using namespace spu::tools;
       7             : 
       8             : bool spu::tools::exception::no_stacktrace = false;
       9             : 
      10           0 : exception::exception() noexcept
      11             : #ifdef SPU_STACKTRACE
      12           0 :   : cpptrace::exception_with_message("")
      13             : #else
      14             :   : message("")
      15             : #endif
      16             : {
      17           0 : }
      18             : 
      19           0 : exception::exception(std::string&& message) noexcept
      20             : #ifdef SPU_STACKTRACE
      21           0 :   : cpptrace::exception_with_message(std::move(message))
      22             : #else
      23             :   : message(message)
      24             : #endif
      25             : {
      26           0 : }
      27             : 
      28       47397 : exception::exception(std::string&& filename, int&& line_num, std::string&& funcname, std::string&& message) noexcept
      29             : #ifdef SPU_STACKTRACE
      30       94691 :   : cpptrace::exception_with_message((!filename.empty() ? "In the '" + filename + "' file" : "") +
      31      189395 :                                      (line_num >= 0 ? " at line " + std::to_string(line_num) : "") +
      32      189379 :                                      (!funcname.empty() ? " ('" + funcname + "' function)" : "") + ": " + "\"" +
      33      142071 :                                      message + "\"")
      34             : #else
      35             :   : message((!filename.empty() ? "In the '" + filename + "' file" : "") +
      36             :             (line_num >= 0 ? " at line " + std::to_string(line_num) : "") +
      37             :             (!funcname.empty() ? " ('" + funcname + "' function)" : "") + ": " + "\"" + message + "\"")
      38             : #endif
      39             : {
      40       47317 : }
      41             : 
      42             : const char*
      43           0 : exception::what() const noexcept
      44             : {
      45             : #ifdef SPU_STACKTRACE
      46           0 :     if (no_stacktrace)
      47             :     {
      48           0 :         return this->message();
      49             :     }
      50             :     else
      51             :     {
      52             : #ifdef SPU_COLORS
      53           0 :         if (what_string.empty())
      54             :         {
      55           0 :             const bool enable_color = true;
      56           0 :             what_string = message() + std::string(":\n") + this->trace().to_string(enable_color);
      57             :         }
      58           0 :         return what_string.c_str();
      59             : #else
      60             :         return cpptrace::exception_with_message::what();
      61             : #endif
      62             :     }
      63             : #else
      64             :     return message.c_str();
      65             : #endif
      66             : }

Generated by: LCOV version 1.14