[gjs: 1/14] fundamental: Improve error message about invalid conversion types
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/14] fundamental: Improve error message about invalid conversion types
- Date: Sat, 17 Apr 2021 04:36:47 +0000 (UTC)
commit d7db762c0dabac434fce2a98d33f5be321878d5f
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Thu Apr 8 16:35:19 2021 +0200
fundamental: Improve error message about invalid conversion types
gi/fundamental.cpp | 9 +++++++--
installed-tests/js/testFundamental.js | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 0e83028c..824e72e1 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -448,7 +448,10 @@ JSObject* FundamentalInstance::object_for_gvalue(JSContext* cx,
cx, g_value_peek_pointer(value));
}
- gjs_throw(cx, "Failed to convert GValue to a fundamental instance");
+ gjs_throw(cx,
+ "Failed to convert GValue of type %s to a fundamental %s "
+ "instance",
+ G_VALUE_TYPE_NAME(value), g_type_name(gtype));
return nullptr;
}
@@ -470,7 +473,9 @@ bool FundamentalBase::to_gvalue(JSContext* cx, JS::HandleObject obj,
}
gjs_throw(cx,
- "Fundamental object does not support conversion to a GValue");
+ "Fundamental object of type %s does not support conversion "
+ "to a GValue of type %s",
+ instance->type_name(), G_VALUE_TYPE_NAME(gvalue));
return false;
}
diff --git a/installed-tests/js/testFundamental.js b/installed-tests/js/testFundamental.js
index 3274cf6c..2467a0e9 100644
--- a/installed-tests/js/testFundamental.js
+++ b/installed-tests/js/testFundamental.js
@@ -45,6 +45,6 @@ describe('Fundamental type support', function () {
const signalSpy = jasmine.createSpy('signalSpy');
obj.connect('test-fundamental-value-funcs', signalSpy);
expect(() => obj.emit('test-fundamental-value-funcs', fund)).toThrowError(
- /conversion to a GValue/);
+ /.* RegressTestFundamentalObjectNoGetSetFunc .* conversion to a GValue.*
RegressTestFundamentalSubObject/);
}).pend('https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/268');
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]