2013-01-20 18:57:04 -05:00
|
|
|
#include "InvocationResult.h"
|
2013-02-02 17:32:54 -05:00
|
|
|
#include "ErrorMessage.h"
|
2013-01-20 18:57:04 -05:00
|
|
|
|
|
|
|
InvocationResult::InvocationResult(QVariant result, bool error) {
|
|
|
|
m_result = result;
|
|
|
|
m_error = error;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QVariant &InvocationResult::result() const {
|
|
|
|
return m_result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InvocationResult::hasError() {
|
|
|
|
return m_error;
|
|
|
|
}
|
2013-02-02 17:32:54 -05:00
|
|
|
|
|
|
|
ErrorMessage *InvocationResult::errorMessage() {
|
|
|
|
if (!m_result.canConvert<QVariantMap>())
|
|
|
|
return new ErrorMessage(m_result.toString());
|
|
|
|
|
|
|
|
QVariantMap error = m_result.toMap();
|
|
|
|
|
|
|
|
QString message = error["message"].toString();
|
|
|
|
|
|
|
|
if (error["name"] == "Capybara.ClickFailed")
|
2013-05-21 07:58:46 -04:00
|
|
|
return new ErrorMessage("ClickFailed", message);
|
2013-12-06 10:43:17 -05:00
|
|
|
else if (error["name"] == "Capybara.NodeNotAttachedError")
|
|
|
|
return new ErrorMessage("NodeNotAttachedError", message);
|
2013-02-02 17:32:54 -05:00
|
|
|
else
|
|
|
|
return new ErrorMessage(message);
|
|
|
|
}
|