Libkleo

kleoexception.h
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  exception.h
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
6 
7  SPDX-License-Identifier: GPL-2.0-or-later
8 */
9 
10 #pragma once
11 
12 #include "kleo_export.h"
13 
14 #include <QString>
15 
16 #include <gpgme++/exception.h>
17 
18 #include <gpg-error.h>
19 
20 namespace Kleo
21 {
22 
23 class KLEO_EXPORT Exception : public GpgME::Exception
24 {
25 public:
26  Exception(gpg_error_t e, const std::string &msg, Options opt = NoOptions)
27  : GpgME::Exception(GpgME::Error(e), msg, opt)
28  {
29  }
30  Exception(gpg_error_t e, const char *msg, Options opt = NoOptions)
31  : GpgME::Exception(GpgME::Error(e), msg, opt)
32  {
33  }
34  Exception(gpg_error_t e, const QString &msg, Options opt = NoOptions)
35  : GpgME::Exception(GpgME::Error(e), msg.toLocal8Bit().constData(), opt)
36  {
37  }
38 
39  Exception(const GpgME::Error &e, const std::string &msg)
40  : GpgME::Exception(e, msg)
41  {
42  }
43  Exception(const GpgME::Error &e, const char *msg)
44  : GpgME::Exception(e, msg)
45  {
46  }
47  Exception(const GpgME::Error &e, const QString &msg)
48  : GpgME::Exception(e, msg.toLocal8Bit().constData())
49  {
50  }
51 
52  ~Exception() throw() override;
53 
54  const std::string &messageLocal8Bit() const
55  {
56  return GpgME::Exception::message();
57  }
58  gpg_error_t error_code() const
59  {
60  return error().encodedError();
61  }
62 
63  QString message() const
64  {
65  return QString::fromLocal8Bit(GpgME::Exception::message().c_str());
66  }
67 };
68 
69 }
QString fromLocal8Bit(const char *str, int size)
typedef Exception
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:56:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.