8#include "MantidJson/Json.h"
18#include <Poco/ActiveResult.h>
27Logger
g_log(
"ErrorReporter");
35 const std::string &exitCode,
const bool share)
36 :
ErrorReporter(application, upTime, exitCode, share,
"",
"",
"",
"") {}
41 const std::string &exitCode,
const bool share,
const std::string &name,
42 const std::string &email,
const std::string &textBox)
43 :
ErrorReporter(application, upTime, exitCode, share, name, email, textBox,
"") {}
46 const bool share, std::string name, std::string email, std::string textBox,
47 std::string traceback)
48 : m_application(
std::move(application)), m_exitCode(
std::move(exitCode)), m_upTime(
std::move(upTime)),
49 m_share(share), m_name(
std::move(name)), m_email(
std::move(email)), m_textbox(
std::move(textBox)),
50 m_stacktrace(
std::move(traceback)) {
52 if (!url.is_initialized()) {
53 g_log.
debug() <<
"Failed to load error report url\n";
70 g_log.
debug() <<
"Send error report failure. " << ex.
what() <<
'\n';
72 }
catch (std::exception &ex) {
73 g_log.
debug() <<
"Send error report failure. " << ex.
what() <<
'\n';
81 ::Json::Value message;
95 message[
"ParaView"] = 0;
101 message[
"dateTime"] = Types::Core::DateAndTime::getCurrentTime().toISO8601String();
103 message[
"upTime"] = to_simple_string(
m_upTime);
117 message[
"email"] =
"";
118 message[
"name"] =
"";
120 message[
"stacktrace"] =
"";
123 return Mantid::JsonHelpers::jsonToString(message);
134 std::stringstream responseStream;
140 g_log.
information() <<
"Call to \"" << url <<
"\" responded with " <<
static_cast<int>(status) <<
"\n"
ErrorReporter : The error reporter is responsible for sending error reports.
virtual Kernel::InternetHelper::HTTPStatus sendReport(const std::string &message, const std::string &url)
Sends report using Internet Helper.
const std::string m_application
const std::string m_exitCode
ErrorReporter(const std::string &application, const Types::Core::time_duration &startTime, const std::string &exitCode, bool share)
Constructor.
Kernel::InternetHelper::HTTPStatus sendErrorReport()
Sends an error report.
virtual std::string generateErrorMessage() const
Generates an error string in json format.
const std::string m_textbox
const std::string m_email
const Types::Core::time_duration m_upTime
const std::string m_stacktrace
Exception thrown when error occurs accessing an internet resource.
const char * what() const noexcept override
Overloaded reporting method.
const int & errorCode() const
Writes out the range and limits.
InternetHelper : A helper class for supporting access to resources through HTTP and HTTPS.
void setBody(const std::string &body)
Sets the body & content length for future requests, this will also set the method to POST is the body...
void setTimeout(int seconds)
Sets the timeout in seconds.
virtual HTTPStatus sendRequest(const std::string &url, std::ostream &responseStream)
Performs a request using http or https depending on the url.
void debug(const std::string &msg)
Logs at debug level.
void information(const std::string &msg)
Logs at information level.
static const char * version()
The full version number.
static const char * revisionFull()
The full SHA-1 of the last commit.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
MANTID_KERNEL_DLL std::string md5FromString(const std::string &input)
create a md5 checksum from a string
Logger g_log("DateAndTime")