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-12-01 18:45:36 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             : #ifdef HAVE_CONFIG_H
      25             :  #include "config.h"
      26             : #endif
      27             : 
      28             : #include "exception.h"
      29             : 
      30             : #include <gpgme.h>
      31             : 
      32             : #include <sstream>
      33             : 
      34             : using namespace GpgME;
      35             : using namespace std; // only safe b/c it's so small a file!
      36             : 
      37           0 : Exception::~Exception() throw() {}
      38             : 
      39             : // static
      40           0 : string Exception::make_message(const Error &err, const string &msg)
      41             : {
      42           0 :     return make_message(err, msg, NoOptions);
      43             : }
      44             : 
      45             : // static
      46           0 : string Exception::make_message(const Error &err, const string &msg, Options opt)
      47             : {
      48           0 :     if (opt & MessageOnly) {
      49           0 :         return msg;
      50             :     }
      51             :     char error_string[128];
      52           0 :     error_string[0] = '\0';
      53           0 :     gpgme_strerror_r(err.encodedError(), error_string, sizeof error_string);
      54           0 :     error_string[sizeof error_string - 1] = '\0';
      55           0 :     stringstream ss;
      56           0 :     ss << gpgme_strsource(err.encodedError()) << ": ";
      57           0 :     if (!msg.empty()) {
      58           0 :         ss << msg << ": ";
      59             :     }
      60           0 :     ss << error_string << " (" << static_cast<unsigned long>(err.encodedError()) << ')';
      61           0 :     return ss.str();
      62             : }

Generated by: LCOV version 1.11