Catch exceptions and add logging
This commit is contained in:
+55
-44
@@ -31,57 +31,68 @@ std::string Decode(const std::string& data)
|
||||
|
||||
void message::processMessage(const std::string& message)
|
||||
{
|
||||
message::state::type state = message::state::header;
|
||||
std::string line;
|
||||
std::istringstream stream(message);
|
||||
while (std::getline(stream, line, '\r'))
|
||||
try
|
||||
{
|
||||
boost::erase_all(line, "\n");
|
||||
switch (state)
|
||||
std::cout << "message::processMessage enter" << std::endl;
|
||||
message::state::type state = message::state::header;
|
||||
std::string line;
|
||||
std::istringstream stream(message);
|
||||
while (std::getline(stream, line, '\r'))
|
||||
{
|
||||
case state::header:
|
||||
state = processHeaderLine(line);
|
||||
break;
|
||||
case state::data:
|
||||
state = processDataLine(line);
|
||||
break;
|
||||
case state::mimeBoundary:
|
||||
state = processMimeBoundary(line);
|
||||
break;
|
||||
case state::image:
|
||||
state = processImage(line);
|
||||
break;
|
||||
boost::erase_all(line, "\n");
|
||||
switch (state)
|
||||
{
|
||||
case state::header:
|
||||
state = processHeaderLine(line);
|
||||
break;
|
||||
case state::data:
|
||||
state = processDataLine(line);
|
||||
break;
|
||||
case state::mimeBoundary:
|
||||
state = processMimeBoundary(line);
|
||||
break;
|
||||
case state::image:
|
||||
state = processImage(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (boost::algorithm::contains(m_contentEncoding, "base64"))
|
||||
{
|
||||
std::string decoded = Decode(m_subject);
|
||||
if (decoded.size() > 0)
|
||||
m_subject = decoded;
|
||||
}
|
||||
|
||||
outputImage image(m_images);
|
||||
|
||||
boost::filesystem::path path(m_context.path);
|
||||
path = boost::filesystem::canonical(path);
|
||||
path /= m_address;
|
||||
|
||||
if (!boost::filesystem::exists(path))
|
||||
boost::filesystem::create_directory(path);
|
||||
|
||||
std::string fileName(getTimeString());
|
||||
fileName.append(".jpg");
|
||||
path /= fileName;
|
||||
|
||||
image.save(path.string());
|
||||
|
||||
if (!m_context.url.empty())
|
||||
{
|
||||
std::stringstream url;
|
||||
url << m_context.url << "?ip=" << m_address << "&file=" << fileName;
|
||||
m_context.client.GetUrlContents(url.str());
|
||||
}
|
||||
}
|
||||
|
||||
if (boost::algorithm::contains(m_contentEncoding, "base64"))
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string decoded = Decode(m_subject);
|
||||
if (decoded.size() > 0)
|
||||
m_subject = decoded;
|
||||
std::cout << "Exception: " << e.what() << std::endl;
|
||||
std::cerr << "Exception: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
outputImage image(m_images);
|
||||
|
||||
boost::filesystem::path path(m_context.path);
|
||||
path = boost::filesystem::canonical(path);
|
||||
path /= m_address;
|
||||
|
||||
if (!boost::filesystem::exists(path))
|
||||
boost::filesystem::create_directory(path);
|
||||
|
||||
std::string fileName(getTimeString());
|
||||
fileName.append(".jpg");
|
||||
path /= fileName;
|
||||
|
||||
image.save(path.string());
|
||||
|
||||
if (!m_context.url.empty())
|
||||
{
|
||||
std::stringstream url;
|
||||
url << m_context.url << "?ip=" << m_address << "&file=" << fileName;
|
||||
m_context.client.GetUrlContents(url.str());
|
||||
}
|
||||
std::cout << "message::processMessage exit" << std::endl;
|
||||
}
|
||||
|
||||
message::state::type message::processHeaderLine(const std::string& line)
|
||||
|
||||
Reference in New Issue
Block a user