Changeset 114:13908f2a987f in rrlib_logging


Ignore:
Timestamp:
05.02.2014 15:06:19 (6 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Added demangling to stream operator for exceptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • messages/tStream.h

    r110 r114  
    6161 
    6262#include <exception> 
     63#include <cxxabi.h> 
     64 
    6365#include "rrlib/time/time.h" 
    6466 
     
    151153  inline tStream &operator << (const std::exception &exception) 
    152154  { 
    153     this->stream << "Exception (" << typeid(exception).name() << "): " << exception.what(); 
    154     return *this; 
    155   } 
    156   inline tStream &operator << (std::exception &exception) 
    157   { 
    158     this->stream << "Exception (" << typeid(exception).name() << "): " << exception.what(); 
     155    this->stream << "Exception ("; 
     156    int status; 
     157    char *demangled = abi::__cxa_demangle(typeid(exception).name(), nullptr, nullptr, &status); 
     158    this->stream << (status == 0 && demangled ? demangled : typeid(exception).name()); 
     159    free(demangled); 
     160    this->stream << "): " << exception.what(); 
    159161    return *this; 
    160162  } 
Note: See TracChangeset for help on using the changeset viewer.