File indexing completed on 2024-05-26 05:24:23
0001 /* -*- mode: c++; c-basic-offset:4 -*- 0002 exception.h 0003 0004 This file is part of libkleopatra, the KDE keymanagement library 0005 SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "kleo_export.h" 0013 0014 #include <QString> 0015 0016 #include <gpgme++/exception.h> 0017 0018 #include <gpg-error.h> 0019 0020 namespace Kleo 0021 { 0022 0023 class KLEO_EXPORT Exception : public GpgME::Exception 0024 { 0025 public: 0026 Exception(gpg_error_t e, const std::string &msg, Options opt = NoOptions) 0027 : GpgME::Exception(GpgME::Error(e), msg, opt) 0028 { 0029 } 0030 Exception(gpg_error_t e, const char *msg, Options opt = NoOptions) 0031 : GpgME::Exception(GpgME::Error(e), msg, opt) 0032 { 0033 } 0034 Exception(gpg_error_t e, const QString &msg, Options opt = NoOptions) 0035 : GpgME::Exception(GpgME::Error(e), msg.toLocal8Bit().constData(), opt) 0036 { 0037 } 0038 0039 Exception(const GpgME::Error &e, const std::string &msg) 0040 : GpgME::Exception(e, msg) 0041 { 0042 } 0043 Exception(const GpgME::Error &e, const char *msg) 0044 : GpgME::Exception(e, msg) 0045 { 0046 } 0047 Exception(const GpgME::Error &e, const QString &msg) 0048 : GpgME::Exception(e, msg.toLocal8Bit().constData()) 0049 { 0050 } 0051 0052 ~Exception() throw() override; 0053 0054 const std::string &messageLocal8Bit() const 0055 { 0056 return GpgME::Exception::message(); 0057 } 0058 gpg_error_t error_code() const 0059 { 0060 return error().encodedError(); 0061 } 0062 0063 QString message() const 0064 { 0065 return QString::fromLocal8Bit(GpgME::Exception::message().c_str()); 0066 } 0067 }; 0068 0069 }