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, std::string cppTraces)
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)), m_cppTraces(
std::move(cppTraces)) {
51 auto url = Mantid::Kernel::ConfigService::Instance().getValue<std::string>(
"errorreports.rooturl");
52 if (!url.has_value()) {
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;
89 message[
"osName"] = ConfigService::Instance().getOSName();
90 message[
"osArch"] = ConfigService::Instance().getOSArchitecture();
91 message[
"osVersion"] = ConfigService::Instance().getOSVersion();
92 message[
"osReadable"] = ConfigService::Instance().getOSVersionReadable();
95 message[
"ParaView"] = 0;
101 message[
"dateTime"] = Types::Core::DateAndTime::getCurrentTime().toISO8601String();
103 message[
"upTime"] = to_simple_string(
m_upTime);
107 message[
"facility"] = ConfigService::Instance().getFacility().name();
118 message[
"email"] =
"";
119 message[
"name"] =
"";
121 message[
"stacktrace"] =
"";
122 message[
"cppCompressedTraces"] =
"";
125 return Mantid::JsonHelpers::jsonToString(message);
136 std::stringstream responseStream;
142 g_log.
information() <<
"Call to \"" << url <<
"\" responded with " <<
static_cast<int>(status) <<
"\n"
ErrorReporter : The error reporter is responsible for sending error reports.
const std::string m_cppTraces
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.
MANTID_KERNEL_DLL std::string md5FromString(const std::string &input)
create a md5 checksum from a string
Logger g_log("DateAndTime")