diff --git a/src/libtomahawk-playdarapi/Api_v1.cpp b/src/libtomahawk-playdarapi/Api_v1.cpp index 8871daa90..3b4e835df 100644 --- a/src/libtomahawk-playdarapi/Api_v1.cpp +++ b/src/libtomahawk-playdarapi/Api_v1.cpp @@ -514,3 +514,14 @@ Api_v1::apiCallFailed( QxtWebRequestEvent* event, const QString& method ) { sendPlain404( event, QString( "Method \"%1\" for API 1.5 not found" ).arg( method ), "Method in API 1.5 not found" ); } + + +void +Api_v1::sendJsonError( QxtWebRequestEvent* event, const QString& message ) +{ + QxtWebPageEvent * e = new QxtWebPageEvent( event->sessionID, event->requestID, QString( "{ result: \"error\", error: \"%1\" }" ).arg( message ).toUtf8().constData() ); + e->contentType = "application/json"; + e->status = 500; + e->statusMessage = "Method call failed."; + postEvent( e ); +} diff --git a/src/libtomahawk-playdarapi/Api_v1.h b/src/libtomahawk-playdarapi/Api_v1.h index 843c388d7..c835f9179 100644 --- a/src/libtomahawk-playdarapi/Api_v1.h +++ b/src/libtomahawk-playdarapi/Api_v1.h @@ -82,6 +82,7 @@ public slots: // load an html template from a file, replace args from map // then serve + void sendJsonError( QxtWebRequestEvent* event, const QString& message ); void sendWebpageWithArgs( QxtWebRequestEvent* event, const QString& filenameSource, const QHash< QString, QString >& args ); void index( QxtWebRequestEvent* event );