diff options
author | wm4 <wm4@nowhere> | 2015-01-01 22:56:57 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-01 22:56:57 +0100 |
commit | 9aa1d711479d4892e7f3c528dd48aad91f8a63de (patch) | |
tree | acbbbf0bb13327c228e308f41257be5dfbfb85f7 /DOCS/client_api_examples/qtexample.cpp | |
parent | 0e9d19cd052e8d1086f4588d8e2d6ab4c1bb4ee8 (diff) | |
download | mpv-9aa1d711479d4892e7f3c528dd48aad91f8a63de.tar.bz2 mpv-9aa1d711479d4892e7f3c528dd48aad91f8a63de.tar.xz |
DOCS/client_api_examples: don't throw char* in C++ code
C++ is the worst language ever, and allows throwing any type, even if it
doesn't make sense. In this case, we were throwing char*, which the
runtime typically treats as opaque, instead of printing it as message if
such an exception was not caught.
Diffstat (limited to 'DOCS/client_api_examples/qtexample.cpp')
-rw-r--r-- | DOCS/client_api_examples/qtexample.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/DOCS/client_api_examples/qtexample.cpp b/DOCS/client_api_examples/qtexample.cpp index 2b8bc15533..756c206916 100644 --- a/DOCS/client_api_examples/qtexample.cpp +++ b/DOCS/client_api_examples/qtexample.cpp @@ -2,6 +2,7 @@ #include <clocale> #include <sstream> +#include <stdexcept> #include <QtGlobal> #include <QFileDialog> @@ -55,7 +56,7 @@ MainWindow::MainWindow(QWidget *parent) : mpv = mpv_create(); if (!mpv) - throw "can't create mpv instance"; + throw std::runtime_error("can't create mpv instance"); // Create a video child window. Force Qt to create a native window, and // pass the window ID to the mpv wid option. Works on: X11, win32, Cocoa @@ -94,7 +95,7 @@ MainWindow::MainWindow(QWidget *parent) : mpv_set_wakeup_callback(mpv, wakeup, this); if (mpv_initialize(mpv) < 0) - throw "mpv failed to initialize"; + throw std::runtime_error("mpv failed to initialize"); } void MainWindow::handle_mpv_event(mpv_event *event) |