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

Generated by: LCOV version 1.11