LCOV - code coverage report
Current view: top level - lang/cpp/src - exception.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 15 0.0 %
Date: 2018-11-14 16:53:58 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /*
       2             :   exception.cpp - exception wrapping a gpgme error
       3             :   Copyright (C) 2007 Klarälvdalens Datakonsult AB
       4             :   2016 Bundesamt für Sicherheit in der Informationstechnik
       5             :   Software engineering by Intevation GmbH
       6             : 
       7             :   This file is part of GPGME++.
       8             : 
       9             :   GPGME++ is free software; you can redistribute it and/or
      10             :   modify it under the terms of the GNU Library General Public
      11             :   License as published by the Free Software Foundation; either
      12             :   version 2 of the License, or (at your option) any later version.
      13             : 
      14             :   GPGME++ is distributed in the hope that it will be useful,
      15             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :   GNU Library General Public License for more details.
      18             : 
      19             :   You should have received a copy of the GNU Library General Public License
      20             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      21             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      22             :   Boston, MA 02110-1301, USA.
      23             : */
      24             : 
      25             : // -*- c++ -*-
      26             : #ifdef HAVE_CONFIG_H
      27             :  #include "config.h"
      28             : #endif
      29             : 
      30             : #include "exception.h"
      31             : 
      32             : #include <gpgme.h>
      33             : 
      34             : #include <sstream>
      35             : 
      36             : using namespace GpgME;
      37             : using namespace std; // only safe b/c it's so small a file!
      38             : 
      39           0 : Exception::~Exception() throw() {}
      40             : 
      41             : // static
      42           0 : string Exception::make_message(const Error &err, const string &msg)
      43             : {
      44           0 :     return make_message(err, msg, NoOptions);
      45             : }
      46             : 
      47             : // static
      48           0 : string Exception::make_message(const Error &err, const string &msg, Options opt)
      49             : {
      50           0 :     if (opt & MessageOnly) {
      51           0 :         return msg;
      52             :     }
      53             :     char error_string[128];
      54           0 :     error_string[0] = '\0';
      55           0 :     gpgme_strerror_r(err.encodedError(), error_string, sizeof error_string);
      56           0 :     error_string[sizeof error_string - 1] = '\0';
      57           0 :     stringstream ss;
      58           0 :     ss << gpgme_strsource(err.encodedError()) << ": ";
      59           0 :     if (!msg.empty()) {
      60           0 :         ss << msg << ": ";
      61             :     }
      62           0 :     ss << error_string << " (" << static_cast<unsigned long>(err.encodedError()) << ')';
      63           0 :     return ss.str();
      64             : }

Generated by: LCOV version 1.13