LCOV - code coverage report
Current view: top level - src/utils/common - UtilExceptions.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 88.1 % 42 37
Test Date: 2025-12-06 15:35:27 Functions: 85.7 % 14 12

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    UtilExceptions.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Christian Roessel
      17              : /// @author  Michael Behrisch
      18              : /// @author  Felix Brack
      19              : /// @date    Mon, 17 Dec 2001
      20              : ///
      21              : // Exceptions for used by some utility classes
      22              : /****************************************************************************/
      23              : #include <config.h>
      24              : 
      25              : // stacktrace is not supported in MAC
      26              : #if defined(HAVE_BOOST) && !defined(__APPLE__)
      27              : #ifdef _MSC_VER
      28              : // needed to avoid problem in boost win winsocket
      29              : #pragma warning(push, 0)
      30              : #define WIN32_LEAN_AND_MEAN
      31              : #define NOMINMAX
      32              : #include <windows.h>
      33              : #include <boost/stacktrace.hpp>
      34              : #pragma warning(pop)
      35              : #else
      36              : #pragma GCC diagnostic push
      37              : #pragma GCC diagnostic ignored "-Wall"
      38              : #pragma GCC diagnostic ignored "-Wextra"
      39              : #include <boost/stacktrace.hpp>
      40              : #pragma GCC diagnostic pop
      41              : #endif
      42              : #endif
      43              : 
      44              : #include "UtilExceptions.h"
      45              : 
      46              : // ===========================================================================
      47              : // class definitions
      48              : // ===========================================================================
      49              : 
      50              : // ---------------------------------------------------------------------------
      51              : // ProcessError - methods
      52              : // ---------------------------------------------------------------------------
      53              : 
      54         2753 : ProcessError::ProcessError() :
      55         2753 :     std::runtime_error(TL("Process Error")) {
      56              :     // process trace
      57         2753 :     processTrace();
      58         2753 : }
      59              : 
      60              : 
      61      4318916 : ProcessError::ProcessError(const std::string& msg) :
      62      4318916 :     std::runtime_error(msg) {
      63              :     // process trace
      64      4318916 :     processTrace();
      65      4318916 : }
      66              : 
      67              : 
      68              : const std::string&
      69            0 : ProcessError::getTrace() const {
      70            0 :     return myTrace;
      71              : }
      72              : 
      73              : 
      74              : void
      75      4321669 : ProcessError::processTrace() {
      76              : // only process if we have boost and we're not in apple
      77              : #if defined(HAVE_BOOST) && !defined(__APPLE__)
      78              :     // declare stacktrace
      79              :     boost::stacktrace::stacktrace st;
      80              :     // convert trace using ostringstream
      81              :     std::ostringstream oss;
      82              :     oss << st;
      83              :     myTrace = oss.str();
      84              : #endif
      85      4321669 : }
      86              : 
      87              : // ---------------------------------------------------------------------------
      88              : // ProcessError - methods
      89              : // ---------------------------------------------------------------------------
      90              : 
      91      4278223 : InvalidArgument::InvalidArgument(const std::string& message) :
      92      4278223 :     ProcessError(message) {
      93      4278223 : }
      94              : 
      95              : // ---------------------------------------------------------------------------
      96              : // ProcessError - methods
      97              : // ---------------------------------------------------------------------------
      98              : 
      99         1296 : EmptyData::EmptyData() :
     100         1296 :     ProcessError(TL("Empty Data")) {
     101         1296 : }
     102              : 
     103              : // ---------------------------------------------------------------------------
     104              : // ProcessError - methods
     105              : // ---------------------------------------------------------------------------
     106              : 
     107        29755 : FormatException::FormatException(const std::string& msg) :
     108        29755 :     ProcessError(msg) {
     109        29755 : }
     110              : 
     111              : // ---------------------------------------------------------------------------
     112              : // ProcessError - methods
     113              : // ---------------------------------------------------------------------------
     114              : 
     115        29589 : NumberFormatException::NumberFormatException(const std::string& data) :
     116        59178 :     FormatException(TLF("Invalid Number Format %", data)) {
     117        29589 : }
     118              : 
     119              : // ---------------------------------------------------------------------------
     120              : // ProcessError - methods
     121              : // ---------------------------------------------------------------------------
     122              : 
     123            8 : TimeFormatException::TimeFormatException(const std::string& data) :
     124           16 :     FormatException(TLF("Invalid Time Format %", data)) {
     125            8 : }
     126              : 
     127              : // ---------------------------------------------------------------------------
     128              : // ProcessError - methods
     129              : // ---------------------------------------------------------------------------
     130              : 
     131           63 : BoolFormatException::BoolFormatException(const std::string& data) :
     132          126 :     FormatException(TLF("Invalid Bool Format %", data)) {
     133           63 : }
     134              : 
     135              : // ---------------------------------------------------------------------------
     136              : // ProcessError - methods
     137              : // ---------------------------------------------------------------------------
     138              : 
     139            6 : OutOfBoundsException::OutOfBoundsException(const std::string& msg) :
     140            6 :     ProcessError(msg) {
     141            6 : }
     142              : 
     143              : 
     144              : // ---------------------------------------------------------------------------
     145              : // ProcessError - methods
     146              : // ---------------------------------------------------------------------------
     147              : 
     148            0 : UnknownElement::UnknownElement() :
     149            0 :     ProcessError(TL("Unknown Element")) {
     150            0 : }
     151              : 
     152              : 
     153          872 : UnknownElement::UnknownElement(const std::string& msg) :
     154          872 :     ProcessError(msg) {
     155          872 : }
     156              : 
     157              : // ---------------------------------------------------------------------------
     158              : // ProcessError - methods
     159              : // ---------------------------------------------------------------------------
     160              : 
     161          103 : IOError::IOError(const std::string& message) :
     162          103 :     ProcessError(message) {
     163          103 : }
        

Generated by: LCOV version 2.0-1