summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukáš Hrázký <lhrazky@redhat.com>2018-06-12 14:51:46 +0200
committerLukáš Hrázký <lhrazky@redhat.com>2018-07-02 12:21:18 +0200
commit8fb16195dca782b4aa5faa82951f734caf31bffe (patch)
tree4eba13b977e9941c7d824e4d16e7f009d137b5b8 /src
parentc656735898732044750165f960f8022871330867 (diff)
Clean up the global try-catch block
Unify the error handling to use exceptions, narrowing down the exit spots for success/error to one each. Signed-off-by: Lukáš Hrázký <lhrazky@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/spice-streaming-agent.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index e0a8459..4eb6f25 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -459,8 +459,6 @@ int main(int argc, char* argv[])
}
}
- int ret = EXIT_SUCCESS;
-
try {
// register built-in plugins
MjpegPlugin::Register(&agent);
@@ -478,13 +476,12 @@ int main(int argc, char* argv[])
Display *display = XOpenDisplay(NULL);
if (display == NULL) {
- syslog(LOG_ERR, "failed to open display\n");
- return EXIT_FAILURE;
+ throw Error("Failed to open X display");
}
+
int event_base, error_base;
if (!XFixesQueryExtension(display, &event_base, &error_base)) {
- syslog(LOG_ERR, "XFixesQueryExtension failed\n");
- return EXIT_FAILURE;
+ throw Error("XFixesQueryExtension failed");
}
Window rootwindow = DefaultRootWindow(display);
XFixesSelectCursorInput(display, rootwindow, XFixesDisplayCursorNotifyMask);
@@ -498,8 +495,8 @@ int main(int argc, char* argv[])
}
catch (std::exception &err) {
syslog(LOG_ERR, "%s\n", err.what());
- ret = EXIT_FAILURE;
+ return EXIT_FAILURE;
}
- return ret;
+ return EXIT_SUCCESS;
}