[glibmm] Derive Glib::Error from std::exception, remove Glib::Exception
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Derive Glib::Error from std::exception, remove Glib::Exception
- Date: Sat, 14 Dec 2019 11:34:01 +0000 (UTC)
commit 2f4a122fa05e9e6514f62112d75d1ee7e4d894f2
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Sat Dec 14 12:31:39 2019 +0100
Derive Glib::Error from std::exception, remove Glib::Exception
Glib::Error::what() returns const char* (was Glib::ustring). It overrides
std::exception::what() that returns const char* and is noexcept.
Fixes #23
glib/glibmm.h | 1 -
glib/glibmm/error.cc | 6 +++---
glib/glibmm/error.h | 6 +++---
glib/glibmm/exception.cc | 39 -----------------------------------
glib/glibmm/exception.h | 36 --------------------------------
glib/glibmm/filelist.am | 2 --
tests/giomm_ioerror/main.cc | 4 ++--
tests/giomm_memoryinputstream/main.cc | 2 +-
tests/giomm_simple/main.cc | 2 +-
9 files changed, 10 insertions(+), 88 deletions(-)
---
diff --git a/glib/glibmm.h b/glib/glibmm.h
index a7587d17..93e3a4ff 100644
--- a/glib/glibmm.h
+++ b/glib/glibmm.h
@@ -99,7 +99,6 @@
#include <glibmm/dispatcher.h>
#include <glibmm/enums.h>
#include <glibmm/error.h>
-#include <glibmm/exception.h>
#include <glibmm/exceptionhandler.h>
#include <glibmm/fileutils.h>
#include <glibmm/interface.h>
diff --git a/glib/glibmm/error.cc b/glib/glibmm/error.cc
index 68c20e18..c8e22fc3 100644
--- a/glib/glibmm/error.cc
+++ b/glib/glibmm/error.cc
@@ -50,7 +50,7 @@ Error::Error(GError* gobject, bool take_copy)
}
Error::Error(const Error& other)
-: Exception(other), gobject_((other.gobject_) ? g_error_copy(other.gobject_) : nullptr)
+: std::exception(other), gobject_((other.gobject_) ? g_error_copy(other.gobject_) : nullptr)
{
}
@@ -99,8 +99,8 @@ Error::code() const
return gobject_->code;
}
-Glib::ustring
-Error::what() const
+const char*
+Error::what() const noexcept
{
g_return_val_if_fail(gobject_ != nullptr, "");
g_return_val_if_fail(gobject_->message != nullptr, "");
diff --git a/glib/glibmm/error.h b/glib/glibmm/error.h
index 5f49ee26..32e3a60c 100644
--- a/glib/glibmm/error.h
+++ b/glib/glibmm/error.h
@@ -18,14 +18,14 @@
*/
#include <glibmmconfig.h>
-#include <glibmm/exception.h>
#include <glibmm/value.h>
#include <glib.h>
+#include <exception>
namespace Glib
{
-class Error : public Glib::Exception
+class Error : public std::exception
{
public:
Error();
@@ -45,7 +45,7 @@ public:
GQuark domain() const;
int code() const;
- Glib::ustring what() const override;
+ const char* what() const noexcept override;
bool matches(GQuark error_domain, int error_code) const;
diff --git a/glib/glibmm/filelist.am b/glib/glibmm/filelist.am
index 530c439f..e606d5fd 100644
--- a/glib/glibmm/filelist.am
+++ b/glib/glibmm/filelist.am
@@ -9,7 +9,6 @@ glibmm_files_extra_cc = \
debug.cc \
dispatcher.cc \
error.cc \
- exception.cc \
exceptionhandler.cc \
extraclassinit.cc \
init.cc \
@@ -42,7 +41,6 @@ glibmm_files_extra_h = \
debug.h \
dispatcher.h \
error.h \
- exception.h \
exceptionhandler.h \
extraclassinit.h \
i18n-lib.h \
diff --git a/tests/giomm_ioerror/main.cc b/tests/giomm_ioerror/main.cc
index 8aaa4298..de312f8a 100644
--- a/tests/giomm_ioerror/main.cc
+++ b/tests/giomm_ioerror/main.cc
@@ -73,9 +73,9 @@ main(int, char**)
else
std::cerr << "Gio::Error exception caught: " << ex.what() << std::endl;
}
- catch (const Glib::Exception& ex)
+ catch (const Glib::Error& ex)
{
- std::cerr << "Exception caught: " << ex.what() << std::endl;
+ std::cerr << "Glib::Error exception caught: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
diff --git a/tests/giomm_memoryinputstream/main.cc b/tests/giomm_memoryinputstream/main.cc
index ce1b54ec..cbf682fb 100644
--- a/tests/giomm_memoryinputstream/main.cc
+++ b/tests/giomm_memoryinputstream/main.cc
@@ -77,7 +77,7 @@ main(int, char**)
return EXIT_FAILURE;
}
}
- catch (const Glib::Exception& ex)
+ catch (const Glib::Error& ex)
{
std::cerr << "Exception caught: " << ex.what() << std::endl;
return EXIT_FAILURE;
diff --git a/tests/giomm_simple/main.cc b/tests/giomm_simple/main.cc
index 7b1e8767..0a73cb51 100644
--- a/tests/giomm_simple/main.cc
+++ b/tests/giomm_simple/main.cc
@@ -49,7 +49,7 @@ main(int, char**)
return EXIT_FAILURE;
}
}
- catch (const Glib::Exception& ex)
+ catch (const Glib::Error& ex)
{
std::cerr << "Exception caught: " << ex.what() << std::endl;
return EXIT_FAILURE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]