summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7be0b57..bf78b52 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -215,12 +215,10 @@ int binding_init() noexcept {
// | (_| | __/ |_) | |_| | (_| | \__ \ || (_| | |_| |_| \__ \ | | |
// \__,_|\___|_.__/ \__,_|\__, |___|___/\__\__,_|\__|\__,_|___/ | | |
// |___/_____| \_\/_/
-void debug_status(struct afb_req req) noexcept {
+void debug_status(struct afb_req req) {
// Quick and dirty, dump current surfaces and layers
AFB_REQ_DEBUG(req, "status");
- CHECK_WAYLAND();
-
auto o = json_object_new_object();
json_object_object_add(o, "surfaces",
to_json(g_wayland->controller->surfaces));
@@ -231,22 +229,28 @@ void debug_status(struct afb_req req) noexcept {
afb_req_success(req, o, "status");
}
-void debug_surfaces(afb_req req) noexcept {
- CHECK_WAYLAND();
-
+void debug_surfaces(afb_req req) {
afb_req_success(req, to_json(g_wayland->controller->surfaces), "surfaces");
}
-void debug_layers(afb_req req) noexcept {
- CHECK_WAYLAND();
-
+void debug_layers(afb_req req) {
afb_req_success(req, to_json(g_wayland->controller->layers), "layers");
}
+#define WRAP(F) \
+ [](afb_req req) noexcept { \
+ CHECK_WAYLAND(); \
+ try { \
+ F(req); \
+ } catch (std::exception & e) { \
+ afb_req_fail_f(req, "failed", "Uncaught exception: %s", e.what()); \
+ } \
+ }
+
const struct afb_verb_v2 verbs[] = {
- {"status", debug_status, NULL, NULL, AFB_SESSION_NONE_V2},
- {"layers", debug_layers, NULL, NULL, AFB_SESSION_NONE_V2},
- {"surfaces", debug_surfaces, NULL, NULL, AFB_SESSION_NONE_V2},
+ {"debug::status", WRAP(debug_status), NULL, NULL, AFB_SESSION_NONE_V2},
+ {"debug::layers", WRAP(debug_layers), NULL, NULL, AFB_SESSION_NONE_V2},
+ {"debug::surfaces", WRAP(debug_surfaces), NULL, NULL, AFB_SESSION_NONE_V2},
{},
};
} // namespace