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.

Conflicts:
	DOCS/client_api_examples/qml/mpvrenderer.cpp
This commit is contained in:
wm4 2015-01-01 22:56:57 +01:00 committed by Diogo Franco (Kovensky)
parent 5c1c8b5fab
commit 58c91c02e2
1 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#include <clocale> #include <clocale>
#include <sstream> #include <sstream>
#include <stdexcept>
#include <QtGlobal> #include <QtGlobal>
#include <QFileDialog> #include <QFileDialog>
@ -55,7 +56,7 @@ MainWindow::MainWindow(QWidget *parent) :
mpv = mpv_create(); mpv = mpv_create();
if (!mpv) 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 // 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 // pass the window ID to the mpv wid option. Works on: X11, win32, Cocoa
@ -92,7 +93,7 @@ MainWindow::MainWindow(QWidget *parent) :
mpv_set_wakeup_callback(mpv, wakeup, this); mpv_set_wakeup_callback(mpv, wakeup, this);
if (mpv_initialize(mpv) < 0) 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) void MainWindow::handle_mpv_event(mpv_event *event)