Better fatal error reporting
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
#include "database/TrackList.hpp"
|
#include "database/TrackList.hpp"
|
||||||
#include "database/User.hpp"
|
#include "database/User.hpp"
|
||||||
|
#include "scrobbling/Exception.hpp"
|
||||||
#include "utils/IConfig.hpp"
|
#include "utils/IConfig.hpp"
|
||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
#include "utils/Service.hpp"
|
#include "utils/Service.hpp"
|
||||||
@@ -321,6 +322,10 @@ namespace Scrobbling::ListenBrainz
|
|||||||
LOG(DEBUG) << "getListens aborted";
|
LOG(DEBUG) << "getListens aborted";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (ec)
|
||||||
|
{
|
||||||
|
throw Exception {"GetListens timer failure: " + std::string {ec.message()} };
|
||||||
|
}
|
||||||
|
|
||||||
startGetListens();
|
startGetListens();
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <boost/asio/bind_executor.hpp>
|
#include <boost/asio/bind_executor.hpp>
|
||||||
|
|
||||||
|
#include "scrobbling/Exception.hpp"
|
||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
#include "utils/String.hpp"
|
#include "utils/String.hpp"
|
||||||
|
|
||||||
@@ -228,9 +229,10 @@ namespace Scrobbling::ListenBrainz
|
|||||||
LOG(DEBUG) << "SendQueue: throttle aborted";
|
LOG(DEBUG) << "SendQueue: throttle aborted";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (ec)
|
||||||
if (ec)
|
{
|
||||||
LOG(ERROR) << "async_wait failed:" << ec.message();
|
throw Exception {"Throttle timer failure: " + std::string {ec.message()} };
|
||||||
|
}
|
||||||
|
|
||||||
_state = State::Idle;
|
_state = State::Idle;
|
||||||
sendNextQueuedRequest();
|
sendNextQueuedRequest();
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "utils/Exception.hpp"
|
||||||
|
|
||||||
|
namespace Scrobbling
|
||||||
|
{
|
||||||
|
|
||||||
|
class Exception : public LmsException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using LmsException::LmsException;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -17,16 +17,32 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "utils/Logger.hpp"
|
|
||||||
#include "utils/IOContextRunner.hpp"
|
#include "utils/IOContextRunner.hpp"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include "utils/Logger.hpp"
|
||||||
|
|
||||||
IOContextRunner::IOContextRunner(boost::asio::io_service& ioService, std::size_t threadCount)
|
IOContextRunner::IOContextRunner(boost::asio::io_service& ioService, std::size_t threadCount)
|
||||||
: _ioService {ioService}
|
: _ioService {ioService}
|
||||||
, _work {ioService}
|
, _work {ioService}
|
||||||
{
|
{
|
||||||
LMS_LOG(UTILS, INFO) << "Starting IO Context with " << threadCount << " threads...";
|
LMS_LOG(UTILS, INFO) << "Starting IO Context with " << threadCount << " threads...";
|
||||||
for (std::size_t i {}; i < threadCount; ++i)
|
for (std::size_t i {}; i < threadCount; ++i)
|
||||||
_threads.emplace_back([&] { _ioService.run(); });
|
{
|
||||||
|
_threads.emplace_back([&]
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ioService.run();
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LMS_LOG(UTILS, FATAL) << "Exception caught in IO context: " << e.what();
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+4
-2
@@ -294,13 +294,15 @@ int main(int argc, char* argv[])
|
|||||||
LMS_LOG(MAIN, INFO) << "Quitting...";
|
LMS_LOG(MAIN, INFO) << "Quitting...";
|
||||||
res = EXIT_SUCCESS;
|
res = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
catch(Wt::WServer::Exception& e)
|
catch (const Wt::WServer::Exception& e)
|
||||||
{
|
{
|
||||||
|
LMS_LOG(MAIN, FATAL) << "Caught WServer::Exception: " << e.what();
|
||||||
std::cerr << "Caught a WServer::Exception: " << e.what() << std::endl;
|
std::cerr << "Caught a WServer::Exception: " << e.what() << std::endl;
|
||||||
res = EXIT_FAILURE;
|
res = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
LMS_LOG(MAIN, FATAL) << "Caught std::exception: " << e.what();
|
||||||
std::cerr << "Caught std::exception: " << e.what() << std::endl;
|
std::cerr << "Caught std::exception: " << e.what() << std::endl;
|
||||||
res = EXIT_FAILURE;
|
res = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user