fixed #2112
This commit is contained in:
parent
edeaf9cbd7
commit
bf76d0f770
6 changed files with 121 additions and 11 deletions
|
@ -114,6 +114,17 @@ class XmlRpcException : public std::exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the message of the exception.
|
||||||
|
*
|
||||||
|
* @param msg the new message of the exception.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setMessage(const std::string & msg) throw ()
|
||||||
|
{
|
||||||
|
message.reset(new std::string(msg));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the message of the exception.
|
* Get the message of the exception.
|
||||||
*
|
*
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
#include "configure.h"
|
#include "configure.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "LiveSupport/Core/XmlRpcException.h"
|
#include "LiveSupport/Core/XmlRpcException.h"
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
|
@ -48,6 +50,14 @@ namespace Core {
|
||||||
|
|
||||||
/* ================================================================ constants */
|
/* ================================================================ constants */
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The default fault code, the value when no fault code is set.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
const int defaultFaultCode = -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* =================================================================== macros */
|
/* =================================================================== macros */
|
||||||
|
|
||||||
|
@ -63,6 +73,13 @@ namespace Core {
|
||||||
*/
|
*/
|
||||||
class XmlRpcMethodFaultException : public XmlRpcException
|
class XmlRpcMethodFaultException : public XmlRpcException
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* The XML-RPC faultCode of the exception.
|
||||||
|
*/
|
||||||
|
int faultCode;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor based on a string.
|
* Constructor based on a string.
|
||||||
|
@ -70,7 +87,8 @@ class XmlRpcMethodFaultException : public XmlRpcException
|
||||||
* @param msg the message of the exception.
|
* @param msg the message of the exception.
|
||||||
*/
|
*/
|
||||||
XmlRpcMethodFaultException(const std::string &msg) throw ()
|
XmlRpcMethodFaultException(const std::string &msg) throw ()
|
||||||
: XmlRpcException(msg)
|
: XmlRpcException(msg),
|
||||||
|
faultCode(defaultFaultCode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +99,13 @@ class XmlRpcMethodFaultException : public XmlRpcException
|
||||||
*/
|
*/
|
||||||
XmlRpcMethodFaultException(const std::exception & parent)
|
XmlRpcMethodFaultException(const std::exception & parent)
|
||||||
throw ()
|
throw ()
|
||||||
: XmlRpcException(parent)
|
: XmlRpcException(parent),
|
||||||
|
faultCode(defaultFaultCode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor based on a message ant a parent exception.
|
* Constructor based on a message and a parent exception.
|
||||||
*
|
*
|
||||||
* @param msg the message of the exception.
|
* @param msg the message of the exception.
|
||||||
* @param parent the parent exception.
|
* @param parent the parent exception.
|
||||||
|
@ -94,10 +113,35 @@ class XmlRpcMethodFaultException : public XmlRpcException
|
||||||
XmlRpcMethodFaultException(const std::string & msg,
|
XmlRpcMethodFaultException(const std::string & msg,
|
||||||
const std::exception & parent)
|
const std::exception & parent)
|
||||||
throw ()
|
throw ()
|
||||||
: XmlRpcException(msg, parent)
|
: XmlRpcException(msg, parent),
|
||||||
|
faultCode(defaultFaultCode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor based on a fault code, fault string pair.
|
||||||
|
*
|
||||||
|
* @param methodName the name of the method throwing the exception.
|
||||||
|
* @param faultCode the code of the exception.
|
||||||
|
* @param faultString the message of the exception.
|
||||||
|
*/
|
||||||
|
XmlRpcMethodFaultException(const std::string & methodName,
|
||||||
|
int faultCode,
|
||||||
|
const std::string & faultString)
|
||||||
|
throw ()
|
||||||
|
: XmlRpcException(""),
|
||||||
|
faultCode(faultCode)
|
||||||
|
{
|
||||||
|
std::stringstream msg;
|
||||||
|
msg << "XML-RPC method '"
|
||||||
|
<< methodName
|
||||||
|
<< "' returned error message:\n"
|
||||||
|
<< faultCode
|
||||||
|
<< " - "
|
||||||
|
<< faultString;
|
||||||
|
setMessage(msg.str());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual destructor.
|
* Virtual destructor.
|
||||||
*/
|
*/
|
||||||
|
@ -105,6 +149,16 @@ class XmlRpcMethodFaultException : public XmlRpcException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the XML-RPC faultCode of the exception.
|
||||||
|
*
|
||||||
|
* @return the fault code, if one is set; or -1 if not.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
getFaultCode(void) const throw ()
|
||||||
|
{
|
||||||
|
return faultCode;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1102,12 +1102,11 @@ WebStorageClient :: execute(const std::string & methodName,
|
||||||
xmlRpcClient.close();
|
xmlRpcClient.close();
|
||||||
|
|
||||||
if (xmlRpcClient.isFault()) {
|
if (xmlRpcClient.isFault()) {
|
||||||
std::stringstream eMsg;
|
int faultCode = result[errorCodeParamName];
|
||||||
eMsg << "XML-RPC method '"
|
std::string faultString = result[errorMessageParamName];
|
||||||
<< methodName
|
throw Core::XmlRpcMethodFaultException(methodName,
|
||||||
<< "' returned error message:\n"
|
faultCode,
|
||||||
<< result;
|
faultString);
|
||||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <fileref.h>
|
#include <fileref.h>
|
||||||
#include <audioproperties.h>
|
#include <audioproperties.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Debug.h"
|
||||||
#include "LiveSupport/Core/TimeConversion.h"
|
#include "LiveSupport/Core/TimeConversion.h"
|
||||||
#include "LiveSupport/Core/FileTools.h"
|
#include "LiveSupport/Core/FileTools.h"
|
||||||
|
|
||||||
|
@ -469,6 +470,11 @@ UploadFileWindow :: uploadAudioClip(void) throw ()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
gLiveSupport->uploadAudioClip(audioClip);
|
gLiveSupport->uploadAudioClip(audioClip);
|
||||||
|
|
||||||
|
} catch (XmlRpcMethodFaultException &e) {
|
||||||
|
statusBar->set_text(*processException(e));
|
||||||
|
return;
|
||||||
|
|
||||||
} catch (XmlRpcException &e) {
|
} catch (XmlRpcException &e) {
|
||||||
statusBar->set_text(e.what());
|
statusBar->set_text(e.what());
|
||||||
std::cerr << e.what();
|
std::cerr << e.what();
|
||||||
|
@ -494,6 +500,11 @@ UploadFileWindow :: uploadPlaylistArchive(void) throw ()
|
||||||
Ptr<Playlist>::Ref playlist;
|
Ptr<Playlist>::Ref playlist;
|
||||||
try {
|
try {
|
||||||
playlist = gLiveSupport->uploadPlaylistArchive(path);
|
playlist = gLiveSupport->uploadPlaylistArchive(path);
|
||||||
|
|
||||||
|
} catch (XmlRpcMethodFaultException &e) {
|
||||||
|
statusBar->set_text(*processException(e));
|
||||||
|
return;
|
||||||
|
|
||||||
} catch (XmlRpcException &e) {
|
} catch (XmlRpcException &e) {
|
||||||
statusBar->set_text(e.what());
|
statusBar->set_text(e.what());
|
||||||
return;
|
return;
|
||||||
|
@ -619,3 +630,25 @@ UploadFileWindow :: clearEverything(void) throw ()
|
||||||
fileType = invalidType;
|
fileType = invalidType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Handle some known exception types.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<const Glib::ustring>::Ref
|
||||||
|
UploadFileWindow :: processException(const XmlRpcMethodFaultException & e)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
Ptr<const Glib::ustring>::Ref message;
|
||||||
|
|
||||||
|
if (e.getFaultCode() == 888) {
|
||||||
|
message = getResourceUstring("duplicateFileMsg");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
message.reset(new const Glib::ustring(e.what()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,17 @@ class UploadFileWindow : public GuiWindow
|
||||||
void
|
void
|
||||||
clearEverything(void) throw ();
|
clearEverything(void) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle some known exception types.
|
||||||
|
*
|
||||||
|
* @param e the exception to be processed.
|
||||||
|
* @return a localized error message if e has one of the recognized
|
||||||
|
* faultCode values; e.what() if not.
|
||||||
|
*/
|
||||||
|
Ptr<const Glib::ustring>::Ref
|
||||||
|
processException(const XmlRpcMethodFaultException & e)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -122,6 +122,8 @@ root:table
|
||||||
unsupportedFileTypeMsg:string { "Unsupported file type." }
|
unsupportedFileTypeMsg:string { "Unsupported file type." }
|
||||||
missingTitleMsg:string { "Please enter a title." }
|
missingTitleMsg:string { "Please enter a title." }
|
||||||
badMetadataMsg:string { "Invalid data for {0}." }
|
badMetadataMsg:string { "Invalid data for {0}." }
|
||||||
|
duplicateFileMsg:string { "Error: the file is in the storage "
|
||||||
|
"already." }
|
||||||
}
|
}
|
||||||
|
|
||||||
simplePlaylistManagementWindow:table
|
simplePlaylistManagementWindow:table
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue