mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-02 04:10:20 +02:00
Add sendJsonError
This commit is contained in:
@@ -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" );
|
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 );
|
||||||
|
}
|
||||||
|
@@ -82,6 +82,7 @@ public slots:
|
|||||||
|
|
||||||
// load an html template from a file, replace args from map
|
// load an html template from a file, replace args from map
|
||||||
// then serve
|
// then serve
|
||||||
|
void sendJsonError( QxtWebRequestEvent* event, const QString& message );
|
||||||
void sendWebpageWithArgs( QxtWebRequestEvent* event, const QString& filenameSource, const QHash< QString, QString >& args );
|
void sendWebpageWithArgs( QxtWebRequestEvent* event, const QString& filenameSource, const QHash< QString, QString >& args );
|
||||||
|
|
||||||
void index( QxtWebRequestEvent* event );
|
void index( QxtWebRequestEvent* event );
|
||||||
|
Reference in New Issue
Block a user