Version upgrade 4.00 #45
2 changed files with 79 additions and 7 deletions
|
@ -3,14 +3,21 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
DoNotCatchException::DoNotCatchException( const char* msg )
|
||||
{
|
||||
std::cerr << "LogDoctor: Exception: " << msg << std::endl;
|
||||
}
|
||||
|
||||
|
||||
/////////////////
|
||||
//// GENERIC ////
|
||||
GenericException::GenericException( const std::string& msg, const bool to_sys )
|
||||
{
|
||||
if ( to_sys ) { // when sys, leave un-catched
|
||||
std::cout << "LogDoctor: Exception: " << msg << std::endl;
|
||||
std::cerr << "LogDoctor: Exception: " << msg << std::endl;
|
||||
std::cerr << "LogDoctor: GenericException: " << msg << std::endl;
|
||||
} else {
|
||||
this->msg = QString::fromStdString( msg );
|
||||
}
|
||||
|
@ -25,7 +32,6 @@ const QString& GenericException::what()
|
|||
//// WEB SERVER ////
|
||||
WebServerException::WebServerException( const std::string& msg ) // leave un-catched
|
||||
{
|
||||
std::cout << "LogDoctor: WebServerException: " << msg << std::endl;
|
||||
std::cerr << "LogDoctor: WebServerException: " << msg << std::endl;
|
||||
/*this->msg = QString::fromStdString( msg );*/
|
||||
}
|
||||
|
@ -39,7 +45,6 @@ WebServerException::WebServerException( const std::string& msg ) // leave un-cat
|
|||
//// LOG FORMAT ////
|
||||
LogFormatException::LogFormatException( const std::string& msg )
|
||||
{
|
||||
std::cout << "LogDoctor: LogFormatException: " << msg << std::endl;
|
||||
std::cerr << "LogDoctor: LogFormatException: " << msg << std::endl;
|
||||
this->msg = QString::fromStdString( msg );
|
||||
}
|
||||
|
@ -53,7 +58,6 @@ const QString& LogFormatException::what()
|
|||
//// LOG PARSER ////
|
||||
LogParserException::LogParserException( const std::string& txt , const std::string& val )
|
||||
{
|
||||
std::cout << "LogDoctor: LogParserException: " << txt << ": '" << val << "'" << std::endl;
|
||||
std::cerr << "LogDoctor: LogParserException: " << txt << ": '" << val << "'" << std::endl;
|
||||
this->msg = QString("%1:\n'%2'").arg(
|
||||
QString::fromStdString( txt ),
|
||||
|
@ -69,7 +73,6 @@ const QString& LogParserException::what()
|
|||
//// DATE-TIME ////
|
||||
DateTimeException::DateTimeException( const std::string& msg ) // leave un-catched
|
||||
{
|
||||
std::cout << "LogDoctor: DateTimeException: " << msg << std::endl;
|
||||
std::cerr << "LogDoctor: DateTimeException: " << msg << std::endl;
|
||||
/*this->msg = QString::fromStdString( msg );*/
|
||||
}
|
||||
|
@ -79,11 +82,23 @@ DateTimeException::DateTimeException( const std::string& msg ) // leave un-catch
|
|||
}*/
|
||||
|
||||
|
||||
////////////////////
|
||||
//// CONVERSION ////
|
||||
ConversionException::ConversionException( const std::string& msg )
|
||||
{
|
||||
//std::cerr << "LogDoctor: ConversionException: " << msg << std::endl;
|
||||
this->msg = QString::fromStdString( msg );
|
||||
}
|
||||
const QString& ConversionException::what()
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
//// BLACK/WARN LISTS ////
|
||||
BWlistException::BWlistException( const std::string& msg )
|
||||
{
|
||||
std::cout << "LogDoctor: BWlistException: " << msg << std::endl;
|
||||
std::cerr << "LogDoctor: BWlistException: " << msg << std::endl;
|
||||
/*this->msg = QString::fromStdString( msg );*/
|
||||
}
|
||||
|
@ -91,3 +106,16 @@ BWlistException::BWlistException( const std::string& msg )
|
|||
{
|
||||
return msg;
|
||||
}*/
|
||||
|
||||
|
||||
//////////////////
|
||||
//// DATABASE ////
|
||||
DatabaseException::DatabaseException( QString&& msg )
|
||||
: msg{ std::move(msg) }
|
||||
{
|
||||
|
||||
}
|
||||
const QString& DatabaseException::what() const noexcept
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,22 @@
|
|||
#include <exception>
|
||||
|
||||
|
||||
//! LogDoctorException
|
||||
/*!
|
||||
Base class for some internal exceptions.
|
||||
Used on its own when a message has already been shown,
|
||||
or there is no need to show one.
|
||||
\see CrapviewException, DatabaseException
|
||||
*/
|
||||
class LogDoctorException {};
|
||||
|
||||
|
||||
struct DoNotCatchException final
|
||||
{
|
||||
explicit DoNotCatchException( const char* msg );
|
||||
};
|
||||
|
||||
|
||||
//! GenericException
|
||||
/*!
|
||||
Generic exception for general purposes
|
||||
|
@ -82,6 +98,20 @@ private:
|
|||
};
|
||||
|
||||
|
||||
//! ConversionException
|
||||
/*!
|
||||
Exception related to failure in converting something
|
||||
*/
|
||||
class ConversionException final : public std::exception {
|
||||
public:
|
||||
explicit ConversionException( const std::string& msg );
|
||||
const QString& what();
|
||||
|
||||
private:
|
||||
QString msg;
|
||||
};
|
||||
|
||||
|
||||
//! BWlistException
|
||||
/*!
|
||||
Exception related to a blacklist/warnlist
|
||||
|
@ -97,4 +127,18 @@ private:
|
|||
};
|
||||
|
||||
|
||||
//! DatabaseException
|
||||
/*!
|
||||
Exception related to the database
|
||||
*/
|
||||
class DatabaseException final : public LogDoctorException {
|
||||
public:
|
||||
explicit DatabaseException( QString&& msg );
|
||||
const QString& what() const noexcept;
|
||||
|
||||
private:
|
||||
QString msg;
|
||||
};
|
||||
|
||||
|
||||
#endif // LOGDOCTOR__EXCEPTIONS_H
|
||||
|
|
Loading…
Reference in a new issue