1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

Add sendJsonError

This commit is contained in:
Uwe L. Korn 2014-01-28 22:39:53 +00:00
parent fcc857a734
commit c87f0c47cd
2 changed files with 12 additions and 0 deletions

View File

@ -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 );
}

View File

@ -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 );