Improved exceptions

This commit is contained in:
Valentino Orlandi 2024-02-09 21:09:42 +01:00
parent b70202078b
commit 8955ab939b
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
48 changed files with 260 additions and 317 deletions

View File

@ -54,7 +54,7 @@ StyleMap makeStyleMap()
"rgb( 27, 30, 33 )"}
};
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
}

View File

@ -8,6 +8,10 @@ class QString;
namespace StyleSec::Games::CrissCross
{
//! Returns the proper style sheet
/*!
\throw DoNotCatchException
*/
QString getStyleSheet();
} // namespace StyleSec::Games::CrissCross

View File

@ -48,7 +48,7 @@ QString getStylesheet()
};
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
break;
}

View File

@ -104,11 +104,11 @@ StyleMap makeStyleMap()
"transparent"}
};
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
}
} // namespace (private)
} //namespace (private)
namespace StyleSec::Games::Snake
@ -127,7 +127,7 @@ QString getStyleSheet()
icons_theme = "light";
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
const StyleMap style{ makeStyleMap() };
return

View File

@ -8,6 +8,10 @@ class QString;
namespace StyleSec::Games::Snake
{
//! Returns the proper style sheet
/*!
\throw DoNotCatchException
*/
QString getStyleSheet();
} // namespace StyleSec::Games::Snake

View File

@ -2,6 +2,8 @@
#define LOGDOCTOR__LIB_H
#include "modules/exceptions.h"
#include <string>
@ -50,8 +52,7 @@ inline std::string toString(const WebServer ws) noexcept
case WebServer::IIS:
return "IIS";
default:
// used in exceptions handling, do not throw
return "?UNKNOWN?";
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(ws)) );
}
}
@ -66,7 +67,7 @@ inline std::string toString(const DialogsLevel lvl)
case DialogsLevel::Explanatory:
return "2";
default:
throw( "Unexpected DialogsLevel: " + std::to_string(static_cast<int>(lvl)) );
throw DoNotCatchException( "Unexpected DialogsLevel", std::to_string(static_cast<int>(lvl)) );
}
}

View File

@ -193,7 +193,7 @@ MainWindow::MainWindow(QWidget *parent)
break;
default:
// shouldn't be here
throw WebServerException( "Unexpected WebServer: " + toString(this->default_web_server) );
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(this->default_web_server)) );
}
this->craplog.setCurrentWebServer( this->default_web_server );
@ -334,7 +334,7 @@ void MainWindow::defineOSspec()
#else
// shouldn't be here
throw GenericException( "Unexpected OS", true );
static_assert( false, "Unexpected OS" );
#endif
}
@ -854,7 +854,7 @@ void MainWindow::readConfigs()
proceed &= false;
invalid_lines.clear();
err_msg = DialogSec::tr("An error occured while reading the configuration file");
} catch (...) {
} catch ( const LogDoctorException& ) {
// something failed
proceed &= false;
invalid_lines.clear();
@ -1225,7 +1225,7 @@ DialogsLevel MainWindow::dialogsLevelFromInt( const int dialogs_level )
if ( dialogs_level >= 0 && dialogs_level <= 2) {
return static_cast<DialogsLevel>( dialogs_level );
} else {
throw GenericException( "Unexpected DialogsLevel: " + std::to_string(dialogs_level), true );
throw DoNotCatchException( "Unexpected DialogsLevel", std::to_string(dialogs_level) );
}
}
@ -1239,7 +1239,7 @@ void MainWindow::setWebServerFromString(const std::string& web_server )
} else if ( web_server == "IIS" || web_server == "13" ) {
this->default_web_server = WebServer::IIS;
} else {
throw GenericException( "Unexpected WebServer: " + web_server, true );
throw DoNotCatchException( "Unexpected WebServer", web_server );
}
}
@ -1297,7 +1297,7 @@ void MainWindow::detectIconsTheme()
GlobalConfigs::icons_set = "light";
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
break;
}
}
@ -1323,7 +1323,7 @@ void MainWindow::updateUiTheme()
break;
default:
// wrong
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
break;
}
// fallback stylesheets
@ -1350,7 +1350,7 @@ void MainWindow::updateUiIcons()
: "dark";
break;
default:
throw GenericException( "Unexpected IconsTheme index: "+std::to_string(static_cast<themes_t>(GlobalConfigs::icons_theme)), true );
throw DoNotCatchException( "Unexpected IconsTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::icons_theme)) );
break;
}
@ -1459,7 +1459,7 @@ void MainWindow::updateUiIcons()
|| text == tr("IIS") ) {
icon_name += "conf_webservers";
} else {
throw GenericException( "Unexpected Configs section: "+text.toStdString(), true );
throw DoNotCatchException( "Unexpected Configs section", text.toStdString() );
}
(*it)->setIcon(0,
QIcon(QStringLiteral(":/icons/icons/%1/%2.png").arg(GlobalConfigs::icons_set, icon_name)) );
@ -2058,7 +2058,7 @@ void MainWindow::makeInitialChecks()
break;
default:
// shouldn't be here
throw WebServerException( "Unexpected WebServer: " + toString(this->default_web_server) );
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(this->default_web_server)) );
}
this->initiating &= false;
// effectively check if draw buttons can be enabled
@ -2114,7 +2114,7 @@ QString MainWindow::wsFromIndex( const int index ) const
case 2:
return QStringLiteral("iis");
default:
throw WebServerException( "Unexpected WebServer index: "+std::to_string( index ) );
throw DoNotCatchException( "Unexpected WebServer index", std::to_string(index) );
}
}
WebServer MainWindow::wsEnumFromIndex( const int index ) const
@ -2127,7 +2127,7 @@ WebServer MainWindow::wsEnumFromIndex( const int index ) const
case 2:
return WS_IIS;
default:
throw WebServerException( "Unexpected WebServer index: "+std::to_string( index ) );
throw DoNotCatchException( "Unexpected WebServer index", std::to_string(index) );
}
}
@ -2202,7 +2202,7 @@ BlacklistField MainWindow::blacklistFieldFromString( const QString& str )
if ( TR::tr(FIELDS__CLIENT.c_str()) == str ) {
return BlacklistField::Client;
}
throw DoNotCatchException( "Unexpected BlacklistField string: "+str.toStdString() );
throw DoNotCatchException( "Unexpected BlacklistField string", str.toStdString() );
}
WarnlistField MainWindow::warnlistFieldFromString( const QString& str )
@ -2216,7 +2216,7 @@ WarnlistField MainWindow::warnlistFieldFromString( const QString& str )
} else if ( TR::tr(FIELDS__USER_AGENT.c_str()) == str ) {
return WarnlistField::UserAgent;
}
throw DoNotCatchException( "Unexpected WarnlistField string: "+str.toStdString() );
throw DoNotCatchException( "Unexpected WarnlistField string", str.toStdString() );
}
@ -4526,7 +4526,7 @@ void MainWindow::on_box_ConfTextBrowser_Font_currentIndexChanged(int index)
case 2:
f = "script"; break;
default:
throw GenericException( "Unexpected Font index: "+std::to_string(index), true );
throw DoNotCatchException( "Unexpected Font index", std::to_string(index) );
}
const QFont& font{ this->fonts.at( f ) };
this->TB.setFont( font );

View File

@ -15,7 +15,7 @@ const Blacklist& Blacklists::getConst( const WebServer ws ) const
return this->iis;
default:
// should be unreachable
throw DoNotCatchException( "Unexpected WebServer" );
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(ws)) );
}
}
@ -30,6 +30,6 @@ Blacklist& Blacklists::get( const WebServer ws )
return this->iis;
default:
// should be unreachable
throw DoNotCatchException( "Unexpected WebServer" );
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(ws)) );
}
}

View File

@ -16,6 +16,6 @@ BlacklistItem& Blacklist::get( const BlacklistField field )
case BlacklistField::Client:
return this->client;
default:
throw DoNotCatchException( "Unexpected BlacklistField" );
throw DoNotCatchException( "Unexpected BlacklistField", std::to_string(static_cast<int>(field)) );
}
}

View File

@ -15,7 +15,7 @@ const char* BlacklistItem::fieldName() const
return FIELDS__CLIENT.c_str();
default:
// should be unreachable
throw DoNotCatchException( "Unexpected BlacklistField" );
throw DoNotCatchException( "Unexpected BlacklistField", std::to_string(static_cast<int>(this->field)) );
}
}
@ -71,6 +71,6 @@ std::string BlacklistItem::sanitized(const std::string& item ) const
return BWutils::sanitizedClient( item );
default:
// should be unreachable
throw DoNotCatchException( "Unexpected BlacklistField" );
throw DoNotCatchException( "Unexpected BlacklistField", std::to_string(static_cast<int>(this->field)) );
}
}

View File

@ -60,7 +60,7 @@ std::unordered_map<std::string, QString> Craphelp::getColorScheme( const ColorsS
default:
// wrong, shouldn't be here
throw GenericException( "Unexpected ColorScheme ID: "+std::to_string( static_cast<themes_t>(scheme_id) ), true ); // leave un-catched
throw DoNotCatchException( "Unexpected ColorScheme", std::to_string(static_cast<themes_t>(scheme_id)) );
}
}

View File

@ -31,6 +31,7 @@ public:
\param path The path of the file resource to be displayed
\param font The font to be used
\param colors_scheme_id The ID of the color-scheme to be used
\throw DoNotCatchException
*/
void helpLogsFormat( const std::string& path, const QFont& font, const ColorsScheme colors_scheme_id ) const noexcept;
@ -41,12 +42,14 @@ public:
\param file_name The file that was supposed to be shown
\param font The font to be used
\param colors_scheme_id The ID of the color-scheme to be used
\throw DoNotCatchException
*/
void helpLogsFormatDefault( std::string_view file_name, const QFont& font, const ColorsScheme colors_scheme_id ) const noexcept;
private:
QSharedPointer<Ui::Craphelp> ui;
// \throw DoNotCatchException
std::unordered_map<std::string, QString> getColorScheme( const ColorsScheme scheme_id ) const;
void defaultApacheFormat( std::string& str ) const noexcept;

View File

@ -119,11 +119,11 @@ StyleMap makeStyleMap()
"rgb( 96, 96, 96 )"}
};
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
}
} // namespace (private)
} //namespace (private)
namespace StyleSec::Crapinfo

View File

@ -8,6 +8,10 @@ class QString;
namespace StyleSec::Crapinfo
{
//! Returns the proper style sheet
/*!
\throw DoNotCatchException
*/
QString getStyleSheet();
} // namespace StyleSec::Crapinfo

View File

@ -191,7 +191,7 @@ QString Craplog::getLogsFormatSample( const WebServer& web_server ) const
case WS_IIS:
return this->formatOps.getIisLogSample( this->logs_formats.at( web_server ) );
default:
throw WebServerException( "Unexpected WebServer: " + toString(web_server) );
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(web_server)) );
}
}
@ -362,7 +362,7 @@ void Craplog::changeIisLogsBaseNames( const IISLogsModule log_module )
this->logs_base_names.at( WS_IIS ).contains = "_in"; break;
default: // shouldn't be reachable
throw GenericException( "Unexpected LogFormatModule ID: "+std::to_string( static_cast<unsigned char>(log_module) ), true ); // leave un-catched
throw DoNotCatchException( "Unexpected LogFormatModule", std::to_string(static_cast<iis_logs_module_t>(log_module)) );
}
}
@ -447,7 +447,7 @@ bool Craplog::isFileNameValid( const std::string& name ) const
}break;
default:
throw WebServerException( "Unexpected WebServer: " + toString(this->current_web_server) );
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(this->current_web_server)) );
}
return true;
@ -637,17 +637,9 @@ void Craplog::showWorkerDialog( const WorkerDialog dialog_type, const QStringLis
DialogSec::errDatabaseNotWritable( args.at(0) );
break;
case WorkerDialog::errDatabaseFailedOpening:
if ( args.size() < 2 ) {
// do not throw, just print to stderr
GenericException{ "call to showWorkerDialog() with invalid number of list items", true };
}
DialogSec::errDatabaseFailedOpening( args.at(0), args.at(1) );
break;
case WorkerDialog::errDatabaseFailedExecuting:
if ( args.size() < 3 ) {
// do not throw, just print to stderr
GenericException{ "call to showWorkerDialog() with invalid number of list items", true };
}
DialogSec::errDatabaseFailedExecuting( args.at(0), args.at(1), args.at(2) );
break;
case WorkerDialog::warnFileNotReadable:

View File

@ -115,6 +115,7 @@ public:
/*!
\param name The name of the file
\return Wheter it does respect the criterions or not
\throw DoNotCatchException
\see LogName
*/
bool isFileNameValid( const std::string& name ) const;
@ -188,6 +189,7 @@ public:
\param format_string The logs format string
\param log_module The IIS logs module to be used to parse the format string
\return Whether the process was successful or not
\throw DoNotCatchException
\see FormatOps, FormatOps::LogsFormat, FormatOps::processIisFormatString()
*/
bool setIisLogFormat( const std::string& format_string, const IISLogsModule log_module ) noexcept;
@ -212,7 +214,7 @@ public:
/*!
\param web_server ID of the Web Server
\return The sample of a log line
\throw WebServerException
\throw DoNotCatchException
\see FormatOps::getApacheLogSample(), FormatOps::getNginxLogSample(), FormatOps::getIisLogSample()
*/
QString getLogsFormatSample( const WebServer& web_server ) const;
@ -401,7 +403,7 @@ private:
//! Changes the name criterions for IIS logs files names depending on the given module
/*!
\param log_module The ID of the module to use to set the criterions
\throw GenericException
\throw DoNotCatchException
\see LogName
*/
void changeIisLogsBaseNames( const IISLogsModule log_module );

View File

@ -2,7 +2,9 @@
#define LOGDOCTOR__CRAPLOG__LIB_H
enum class IISLogsModule : unsigned char {
typedef unsigned char iis_logs_module_t;
enum class IISLogsModule : iis_logs_module_t {
W3C = 0,
NCSA = 1,
IIS = 2

View File

@ -52,7 +52,7 @@ const std::string convertMonth( std::string_view month )
return "12";
} else {
// nope
throw DateTimeException("Unexpected month format: "+std::string{month});
throw DateTimeException("Unexpected month format", std::string{month});
}
}
@ -116,7 +116,7 @@ std::vector<std::string> processDateTime( std::string_view datetime_, const Logs
second = datetime.substr( 6ul, 2ul );
} else [[unlikely]] {
// wronthing went some ...
throw DateTimeException("Unexpected DateTime UTC: "+std::string{datetime_}+" - format: "+std::to_string(format));
throw DateTimeException("Unexpected DateTime UTC", std::string{datetime_}+" - format: "+std::to_string(format));
}
} else if ( _DATE_TIME_EPOCH & format ) {
@ -132,7 +132,7 @@ std::vector<std::string> processDateTime( std::string_view datetime_, const Logs
datetime = std::to_string( std::stoi( datetime ) );
} else if ( format != date_time_epoch_s ) [[unlikely]] {
// wronthing went some ...
throw DateTimeException("Unexpected DateTime EPOCH: "+std::string{datetime_}+" - format: "+std::to_string(format));
throw DateTimeException("Unexpected DateTime EPOCH", std::string{datetime_}+" - format: "+std::to_string(format));
}
// convert to iso date format
const QDateTime e{ QDateTime::fromSecsSinceEpoch( std::stoi( datetime ) ) };
@ -179,7 +179,7 @@ std::vector<std::string> processDateTime( std::string_view datetime_, const Logs
} else [[unlikely]] {
// wronthing went some ...
throw DateTimeException("Unexpected DateTime DATE: "+std::string{datetime_}+" - format: "+std::to_string(format));
throw DateTimeException("Unexpected DateTime DATE", std::string{datetime_}+" - format: "+std::to_string(format));
}
} else if ( _DATE_TIME_CLOCK & format ) {
@ -202,7 +202,7 @@ std::vector<std::string> processDateTime( std::string_view datetime_, const Logs
} else [[unlikely]] {
// wronthing went some ...
throw DateTimeException("Unexpected DateTime CLOCK: "+std::string{datetime_}+" - format: "+std::to_string(format));
throw DateTimeException("Unexpected DateTime CLOCK", std::string{datetime_}+" - format: "+std::to_string(format));
}
} else if ( _DATE_TIME_YEAR & format ) {
@ -235,7 +235,7 @@ std::vector<std::string> processDateTime( std::string_view datetime_, const Logs
} else [[unlikely]] {
// wronthing went some ...
throw DateTimeException("Unexpected DateTime: "+std::string{datetime_}+" - format: "+std::to_string(format));
throw DateTimeException("Unexpected DateTime", std::string{datetime_}+" - format: "+std::to_string(format));
}
return { year, month, day, hour, minute, second };

View File

@ -30,7 +30,7 @@ public:
/*!
\param db_path The path of the log files' Hashes database
\return Whether the operation has been successful or not
\throw LogDoctorException
\throw VoidException
*/
bool loadUsedHashesLists( const std::string& db_path ) noexcept;
@ -56,7 +56,7 @@ public:
\param db_path The path of the Hashes database
\param hashes The list of hashes to insert
\param web_server_id The ID of the Web Server which generated the file
\throw LogDoctorException
\throw VoidException
*/
void insertUsedHashes( const std::string& db_path, const std::vector<std::string>& hashes, const WebServer& web_server );

View File

@ -12,18 +12,18 @@ struct LogsFormat;
//! Signals which dialog to show
enum class WorkerDialog {
errGeneric,
errDirNotExists,
errFailedDefiningLogType,
errFailedParsingLogs,
errDatabaseFileNotFound,
errDatabaseFileNotFile,
errDatabaseFileNotReadable,
errDatabaseFileNotWritable,
errDatabaseFailedOpening,
errDatabaseFailedExecuting,
warnFileNotReadable,
warnEmptyFile,
errGeneric, // 1 arg
errDirNotExists, // 1 arg
errFailedDefiningLogType, // 1 arg
errFailedParsingLogs, // 1 arg
errDatabaseFileNotFound, // 1 arg
errDatabaseFileNotFile, // 1 arg
errDatabaseFileNotReadable, // 1 arg
errDatabaseFileNotWritable, // 1 arg
errDatabaseFailedOpening, // 2 args
errDatabaseFailedExecuting, // 3 args
warnFileNotReadable, // 1 arg
warnEmptyFile, // 1 arg
};
Q_DECLARE_METATYPE(WorkerDialog)

View File

@ -393,8 +393,8 @@ bool CraplogParser::storeData( QSqlDatabase& db )
table.append( "iis" );
break;
default:
// wrong WebServerID, but should be unreachable because of the previous operations
throw WebServerException( "Unexpected WebServer: " + toString(this->web_server) );
// wrong WebServer, but should be unreachable because of the previous operations
throw LogParserException( "Unexpected WebServer", std::to_string(static_cast<int>(this->web_server)) );
}
const QString stmt_template{

View File

@ -44,11 +44,11 @@ StyleMap makeStyleMap()
"rgb( 27, 30, 33 )"}
};
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
}
} // namespacce (private)
} //namespace (private)
namespace StyleSec::Crapup

View File

@ -8,6 +8,10 @@ class QString;
namespace StyleSec::Crapup
{
//! Returns the proper style sheet
/*!
\throw DoNotCatchException
*/
QString getStyleSheet();
} // namespacce StyleSec::Crapup

View File

@ -55,7 +55,7 @@ void Crapview::refreshDates()
this->dbQuery.refreshDates( result );
} catch ( const LogDoctorException& ) {
} catch ( const VoidException& ) {
// dialog already shown
return;
}
@ -183,7 +183,7 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C
DialogSec::errProcessingStatsData( e.what() );
return;
} catch ( const LogDoctorException& ) {
} catch ( const VoidException& ) {
// dialog already shown
return;
}
@ -407,7 +407,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart::
DialogSec::errProcessingStatsData( e.what() );
return;
} catch ( const LogDoctorException& ) {
} catch ( const VoidException& ) {
// dialog already shown
return;
}
@ -561,7 +561,7 @@ void Crapview::drawCount( QTableWidget* table, QChartView* chart, const QChart::
DialogSec::errProcessingStatsData( e.what() );
return;
} catch ( const LogDoctorException& ) {
} catch ( const VoidException& ) {
// dialog already shown
return;
}
@ -634,7 +634,7 @@ void Crapview::drawDay( QChartView* chart, const QChart::ChartTheme& theme, cons
DialogSec::errProcessingStatsData( e.what() );
return;
} catch ( const LogDoctorException& ) {
} catch ( const VoidException& ) {
// dialog already shown
return;
}
@ -766,7 +766,7 @@ void Crapview::drawRelat( QChartView* chart, const QChart::ChartTheme& theme, co
DialogSec::errProcessingStatsData( e.what() );
return;
} catch ( const LogDoctorException& ) {
} catch ( const VoidException& ) {
// dialog already shown
return;
}
@ -885,7 +885,7 @@ bool Crapview::calcGlobals( std::vector<std::tuple<QString,QString>>& recur_list
DialogSec::errProcessingStatsData( e.what() );
return false;
} catch ( const LogDoctorException& ) {
} catch ( const VoidException& ) {
// dialog already shown
return false;
}

View File

@ -25,7 +25,7 @@ int toInt( const QString& str )
QStringLiteral("QString"),
QStringLiteral("int"),
str );
throw LogDoctorException{};
throw VoidException{};
}
return result;
}
@ -38,7 +38,7 @@ int toInt( QStringView str )
QStringLiteral("QStringView"),
QStringLiteral("int"),
str.toString() );
throw LogDoctorException{};
throw VoidException{};
}
return result;
}
@ -49,7 +49,7 @@ int toInt( const QVariant& v )
QStringLiteral("QVariant"),
QStringLiteral("int"),
v.toString() );
throw LogDoctorException{};
throw VoidException{};
}
return v.toInt();
}
@ -61,7 +61,7 @@ QString toString( const QVariant& v )
QStringLiteral("QVariant"),
QStringLiteral("QString"),
v.toString() );
throw LogDoctorException{};
throw VoidException{};
}
return v.toString();
}
@ -84,7 +84,7 @@ int DbQuery::getMinuteGap( const int minute, const int gap )
int m{ -1 };
if ( minute < 0 || minute >= 60 ) {
// unexpected value
throw DateTimeException( "Unexpected Minute: " + std::to_string( minute ) );
throw DateTimeException( "Unexpected Minute", std::to_string( minute ) );
}
int n{ 0 };
for ( int g{0}; g<60; g+=gap ) {
@ -115,7 +115,7 @@ int DbQuery::getMonthDays( const int year, const int month )
case 12: n_days = 31; break;
default:
// unexpected month
throw DateTimeException( "Unexpected Month number: " + std::to_string( month ) );
throw DateTimeException( "Unexpected Month number", std::to_string( month ) );
}
return n_days;
}
@ -128,7 +128,7 @@ int DbQuery::getMonthNumber( QStringView month_str ) const
return num;
}
}
throw DateTimeException( "Unexpected Month name: " + month_str.toString().toStdString() );
throw DateTimeException( "Unexpected Month name", month_str.toString().toStdString() );
}

View File

@ -83,7 +83,7 @@ public:
//! Refreshes the dates which are available in the database
/*!
\param result Holds the data only if the operation completed succssfully
\throw LogDoctorException
\throw VoidException
\throw ConversionException
*/
void refreshDates( std::optional<database_dates_t>& result ) noexcept;
@ -97,7 +97,7 @@ public:
\param month_ The month
\param day_ The day
\param hour_ The hour
\throw LogDoctorException
\throw VoidException
\throw ConversionException
\throw DateTimeException
*/
@ -123,7 +123,7 @@ public:
\param uri_f The filter for the URI field
\param query_f The filter for the Query field
\param response_f The filter for the Response field
\throw LogDoctorException
\throw VoidException
\throw CrapviewException
\throw ConversionException
\throw DateTimeException
@ -150,7 +150,7 @@ public:
\param month The month
\param day The day
\param log_field The log field
\throw LogDoctorException
\throw VoidException
\throw CrapviewException
\throw DateTimeException
*/
@ -176,7 +176,7 @@ public:
\param to_day_ The final day
\param log_field_ The log field to filter
\param field_filter The filter to apply
\throw LogDoctorException
\throw VoidException
\throw CrapviewException
\throw ConversionException
\throw DateTimeException
@ -202,7 +202,7 @@ public:
\param field_filter_1 The filter to apply to the first field
\param log_field_2_ The second log field to filter
\param field_filter_2 The filter to apply to the second fiend
\throw LogDoctorException
\throw VoidException
\throw CrapviewException
\throw ConversionException
\throw DateTimeException
@ -231,7 +231,7 @@ public:
\param field_filter_1 The filter to apply to the first field
\param log_field_2_ The second log field to filter
\param field_filter_2 The filter to apply to the second fiend
\throw LogDoctorException
\throw VoidException
\throw CrapviewException
\throw ConversionException
\throw DateTimeException
@ -252,7 +252,7 @@ public:
\param result Holds the data only if the operation completed succssfully
\param web_server The ID of the Web Server to use
\param dates The dates to query
\throw LogDoctorException
\throw VoidException
\throw CrapviewException
\throw ConversionException
*/

View File

@ -43,10 +43,10 @@ void DatabaseWrapper::open( const std::string& path, const bool explain_err )
{
this->db.setDatabaseName( QString::fromStdString( path ));
if ( ! CheckSec::checkDatabaseFile( path, this->db_name ) ) {
throw LogDoctorException();
throw VoidException();
} else if ( ! this->db.open() ) {
DialogSec::errDatabaseFailedOpening( this->db_name, explain_err ? this->db.lastError().text() : QString{} );
throw LogDoctorException();
throw VoidException();
}
}
@ -55,7 +55,7 @@ void DatabaseWrapper::openNew( const std::string& path )
this->db.setDatabaseName( QString::fromStdString( path ));
if ( ! this->db.open() ) {
DialogSec::errDatabaseFailedOpening( this->db_name, db.lastError().text() );
throw LogDoctorException();
throw VoidException();
}
}
@ -66,7 +66,7 @@ void DatabaseWrapper::startTransaction(const bool explain_msg, const bool explai
db_name,
explain_msg ? QStringLiteral("db.transaction()") : QString(),
explain_err ? this->db.lastError().text() : QString() );
throw LogDoctorException();
throw VoidException();
}
this->ongoing_transaction |= true;
}
@ -78,7 +78,7 @@ void DatabaseWrapper::commitTransaction( const bool explain_msg, const bool expl
db_name,
explain_msg ? QStringLiteral("db.commit()") : QString(),
explain_err ? this->db.lastError().text() : QString() );
throw LogDoctorException();
throw VoidException();
}
this->ongoing_transaction &= false;
}
@ -90,7 +90,7 @@ void DatabaseWrapper::rollbackTransaction( const bool explain_msg, const bool ex
db_name,
explain_msg ? QStringLiteral("db.rollback()") : QString(),
explain_err ? this->db.lastError().text() : QString() );
throw LogDoctorException();
throw VoidException();
}
this->ongoing_transaction &= false;
}
@ -109,7 +109,7 @@ void QueryWrapper::operator()( const QString& text )
{
if ( !query.exec( text ) ) {
DialogSec::errDatabaseFailedExecuting( db_name, query.lastQuery(), query.lastError().text() );
throw LogDoctorException();
throw VoidException();
}
}
@ -151,7 +151,7 @@ DatabaseWrapper DatabaseHandler::get( const DatabaseType db_type, const bool rea
case DatabaseType::Hashes:
return DatabaseWrapper( DatabasesConnections::hashes, QString(DatabasesNames::hashes), readonly );
default:
throw DoNotCatchException( "Unexpected DatabaseType" );
throw DoNotCatchException( "Unexpected DatabaseType", std::to_string(static_cast<int>(db_type)) );
}
}

View File

@ -50,7 +50,7 @@ public:
//! Opens the database file at the given path
/*!
Throws if the file cannot be opened or if opening fails
\throw LogDoctorException
\throw VoidException
*/
void open( const std::string& path, const bool explain_err );
@ -58,28 +58,28 @@ public:
/*!
Used when creating a new database file.
Throws if opening fails.
\throw LogDoctorException
\throw VoidException
*/
void openNew( const std::string& path );
//! Starts an ACID transaction on the database
/*!
Throws in case of failure
\throw LogDoctorException
\throw VoidException
*/
void startTransaction( const bool explain_msg, const bool explain_err );
//! Commits an ongoing transaction
/*!
Throws in case of failure
\throw LogDoctorException
\throw VoidException
*/
void commitTransaction( const bool explain_msg, const bool explain_err );
//! Rolls back an ongoing transaction
/*!
Throws in case of failure
\throw LogDoctorException
\throw VoidException
*/
void rollbackTransaction( const bool explain_msg, const bool explain_err );
@ -119,7 +119,7 @@ public:
//! Executes the query using the internal statement
/*!
Throws in case of failure
\throw LogDoctorException
\throw VoidException
*/
inline void operator ()()
{ operator()(stmt); }
@ -127,7 +127,7 @@ public:
//! Executes the query using the given statement
/*!
Throws in case of failure
\throw LogDoctorException
\throw VoidException
*/
void operator ()( const QString& text );

View File

@ -48,8 +48,7 @@ QString getStylesheet()
};
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
break;
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
return

View File

@ -48,8 +48,7 @@ QString getStylesheet()
};
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
break;
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
return

View File

@ -13,9 +13,6 @@
#include <unordered_map> // leave this here for clang
namespace /*private*/
{
enum StyleId : uint32_t {
TEXT,
WINDOW,
@ -87,8 +84,7 @@ QString getStylesheet()
};
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
break;
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
return
@ -142,8 +138,6 @@ QString getStylesheet()
"}";
}
} //namespace (private)
DialogMsg::DialogMsg(const QString& title, const QString& text, const QString& additional, const MsgType type, QWidget* parent )
: QDialog{ parent }

View File

@ -6,21 +6,18 @@
#include <QString>
DoNotCatchException::DoNotCatchException( const std::string& msg )
DoNotCatchException::DoNotCatchException( const char* header, const std::string& body )
{
std::cerr << "LogDoctor: Exception: " << msg << std::endl;
std::cerr << "LogDoctor: Exception: " << header << ": " << body << std::endl;
}
/////////////////
//// GENERIC ////
GenericException::GenericException( const std::string& msg, const bool to_sys )
GenericException::GenericException( const std::string& msg )
: msg{ QString::fromStdString( msg ) }
{
if ( to_sys ) { // when sys, leave un-catched
std::cerr << "LogDoctor: GenericException: " << msg << std::endl;
} else {
this->msg = QString::fromStdString( msg );
}
}
const QString& GenericException::what()
{
@ -28,19 +25,6 @@ const QString& GenericException::what()
}
////////////////////
//// WEB SERVER ////
WebServerException::WebServerException( const std::string& msg ) // leave un-catched
{
std::cerr << "LogDoctor: WebServerException: " << msg << std::endl;
/*this->msg = QString::fromStdString( msg );*/
}
/*const QString& WebServerException::what()
{
return msg;
}*/
////////////////////
//// LOG FORMAT ////
LogFormatException::LogFormatException( const std::string& msg )
@ -71,27 +55,9 @@ const QString& LogParserException::what()
///////////////////
//// DATE-TIME ////
DateTimeException::DateTimeException( const std::string& msg ) // leave un-catched
DateTimeException::DateTimeException( const char* header, const std::string& body )
{
std::cerr << "LogDoctor: DateTimeException: " << msg << std::endl;
/*this->msg = QString::fromStdString( msg );*/
}
/*const QString& DateTimeException::what()
{
return msg;
}*/
////////////////////
//// 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;
std::cerr << "LogDoctor: DateTimeException: " << header << ": " << body << std::endl;
}
@ -100,12 +66,7 @@ const QString& ConversionException::what()
BWlistException::BWlistException( const std::string& msg )
{
std::cerr << "LogDoctor: BWlistException: " << msg << std::endl;
/*this->msg = QString::fromStdString( msg );*/
}
/*const QString& DateTimeException::what()
{
return msg;
}*/
//////////////////

View File

@ -4,52 +4,45 @@
#include <QString>
#include <exception>
//! VoidException
/*!
Base class for some internal exceptions.
Used when a message has already been shown,
or there is no need to show one.
*/
class VoidException {};
//! DoNotCatchException
/*!
Thrown when something really unexptional happens.
It's not supposed to be catched.
*/
struct DoNotCatchException final
{
explicit DoNotCatchException( const char* header, const std::string& body );
};
//! 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
*/
Base class for internal exceptions
*/
class LogDoctorException {};
struct DoNotCatchException final
{
explicit DoNotCatchException( const std::string& msg );
};
//! GenericException
/*!
Generic exception for general purposes
*/
class GenericException final : public std::exception {
class GenericException final : public LogDoctorException {
public:
explicit GenericException( const std::string& msg, const bool to_sys=false );
explicit GenericException( const std::string& msg );
const QString& what();
private:
QString msg;
using std::exception::what;
};
//! WebServerException
/*!
Exception related to a Web Server
*/
class WebServerException final : public std::exception {
public:
explicit WebServerException( const std::string& msg );
/*const QString& what();
private:
QString msg;
using std::exception::what;*/
};
@ -57,14 +50,13 @@ private:
/*!
Exception related to a Logs Format
*/
class LogFormatException final : public std::exception {
class LogFormatException final : public LogDoctorException {
public:
explicit LogFormatException( const std::string& msg );
const QString& what();
private:
QString msg;
using std::exception::what;
};
@ -72,14 +64,13 @@ private:
/*!
Exception related to the logs parser
*/
class LogParserException final : public std::exception {
class LogParserException final : public LogDoctorException {
public:
explicit LogParserException( const std::string& txt, const std::string& val );
const QString& what();
private:
QString msg;
using std::exception::what;
};
@ -87,28 +78,9 @@ private:
/*!
Exception related to a date/time
*/
class DateTimeException final : public std::exception {
class DateTimeException final : public LogDoctorException {
public:
explicit DateTimeException( const std::string& msg );
/*const QString& what();
private:
QString msg;
using std::exception::what;*/
};
//! 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;
explicit DateTimeException( const char* header, const std::string& body );
};
@ -116,14 +88,9 @@ private:
/*!
Exception related to a blacklist/warnlist
*/
class BWlistException final : public std::exception {
class BWlistException final : public LogDoctorException {
public:
explicit BWlistException( const std::string& msg );
/*const QString& what();
private:
QString msg;
using std::exception::what;*/
};

View File

@ -25,6 +25,6 @@ WarnlistItem& Warnlist::get( const WarnlistField field )
case WarnlistField::UserAgent:
return this->user_agent;
default:
throw DoNotCatchException( "Unexpected WarnlistField" );
throw DoNotCatchException( "Unexpected WarnlistField", std::to_string(static_cast<int>(field)) );
}
}

View File

@ -21,7 +21,7 @@ const char* WarnlistItem::fieldName() const
return FIELDS__USER_AGENT.c_str();
default:
// should be unreachable
throw DoNotCatchException( "Unexpected WarnlistField" );
throw DoNotCatchException( "Unexpected WarnlistField", std::to_string(static_cast<int>(this->field)) );
}
}
@ -83,6 +83,6 @@ std::string WarnlistItem::sanitized( const std::string& item ) const
return BWutils::sanitizedUserAgent( item );
default:
// should be unreachable
throw DoNotCatchException( "Unexpected WarnlistField" );
throw DoNotCatchException( "Unexpected WarnlistField", std::to_string(static_cast<int>(this->field)) );
}
}

View File

@ -15,6 +15,6 @@ Warnlist& Warnlists::get( const WebServer ws )
return this->iis;
default:
// should be unreachable
throw DoNotCatchException( "Unexpected WebServer" );
throw DoNotCatchException( "Unexpected WebServer", std::to_string(static_cast<int>(ws)) );
}
}

View File

@ -51,7 +51,7 @@ void Crapnote::setColorScheme( const ColorsScheme colors_scheme )
break;
default:
// wrong
throw GenericException( "Unexpected ColorScheme ID for Crapnote: "+std::to_string( static_cast<themes_t>(colors_scheme) ), true ); // leave un-catched
throw DoNotCatchException( "Unexpected ColorScheme for Crapnote", std::to_string(static_cast<themes_t>(colors_scheme)) );
}
this->ui->text_Note->setPalette( p );
}

View File

@ -28,6 +28,9 @@ public:
void setTextFont( QFont font ) noexcept;
//! Sets the given color-scheme
/*!
\throw DoNotCatchException
*/
void setColorScheme( const ColorsScheme colors_scheme );

View File

@ -69,11 +69,11 @@ StyleMap makeStyleMap()
"rgb( 47, 99, 47 )"}
};
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
}
} // namespacce (private)
} //namespace (private)
namespace StyleSec::Crapnote
@ -92,7 +92,7 @@ QString getStyleSheet( const ColorsScheme colors_scheme )
icons_theme = "light";
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
QString note_bg, note_txt;
switch ( colors_scheme ) {
@ -119,7 +119,7 @@ QString getStyleSheet( const ColorsScheme colors_scheme )
break;
default:
// wrong
throw GenericException( "Unexpected ColorScheme ID for Crapnote: "+std::to_string( static_cast<themes_t>(colors_scheme) ), true ); // leave un-catched
throw DoNotCatchException( "Unexpected ColorScheme for Crapnote", std::to_string(static_cast<themes_t>(colors_scheme)) );
}
const StyleMap style{ makeStyleMap() };

View File

@ -10,6 +10,10 @@ class QString;
namespace StyleSec::Crapnote
{
//! Returns the proper style sheet
/*!
\throw DoNotCatchException
*/
QString getStyleSheet( const ColorsScheme colors_scheme );
} // namespacce StyleSec::Crapnote

View File

@ -8,7 +8,72 @@
#include <unordered_map>
QString makeStyleSheet();
namespace /*private*/
{
enum StyleId : uint32_t {
BUTTONS_BASE,
BUTTONS_BASE_HOVER,
BUTTONS_BASE_FLAT,
BUTTONS_BASE_DISABLED
};
using StyleMap = std::unordered_map<StyleId, QString>;
StyleMap makeStyleMap()
{
switch ( GlobalConfigs::window_theme ) {
case WindowTheme::Light:
return {
{BUTTONS_BASE,
"rgb( 99, 188, 255 )"},
{BUTTONS_BASE_HOVER,
"rgb( 123, 201, 255 )"},
{BUTTONS_BASE_FLAT,
"rgb( 200, 219, 238 )"},
{BUTTONS_BASE_DISABLED,
"rgb( 200, 219, 238 )"}
};
case WindowTheme::Dark:
return {
{BUTTONS_BASE,
"rgb( 10, 155, 10 )"},
{BUTTONS_BASE_HOVER,
"rgb( 33, 162, 33 )"},
{BUTTONS_BASE_FLAT,
"rgb( 21, 71, 21 )"},
{BUTTONS_BASE_DISABLED,
"rgb( 21, 71, 21 )"}
};
default:
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
}
}
QString makeStyleSheet()
{
const StyleMap style{ makeStyleMap() };
return
"QPushButton {"
" border: 0px;"
" border-radius: 8px;"
" padding-left: 4px;"
" padding-right: 4px;"
" background-color: "+style.at(BUTTONS_BASE)+";"
"}"
"QPushButton:hover {"
" background-color: "+style.at(BUTTONS_BASE_HOVER)+";"
"}"
"QPushButton::flat {"
" background-color: "+style.at(BUTTONS_BASE_FLAT)+";"
"}"
"QPushButton::disabled {"
" background-color: "+style.at(BUTTONS_BASE_DISABLED)+";"
"}";
}
} //namespace (private)
Crappath::Crappath( QWidget* parent )
@ -44,70 +109,7 @@ Crappath::Crappath( QWidget* parent )
break;
default:
// wrong
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
break;
}
}
enum StyleId : uint32_t {
BUTTONS_BASE,
BUTTONS_BASE_HOVER,
BUTTONS_BASE_FLAT,
BUTTONS_BASE_DISABLED
};
using StyleMap = std::unordered_map<StyleId, QString>;
StyleMap makeStyleMap()
{
switch ( GlobalConfigs::window_theme ) {
case WindowTheme::Light:
return {
{BUTTONS_BASE,
"rgb( 99, 188, 255 )"},
{BUTTONS_BASE_HOVER,
"rgb( 123, 201, 255 )"},
{BUTTONS_BASE_FLAT,
"rgb( 200, 219, 238 )"},
{BUTTONS_BASE_DISABLED,
"rgb( 200, 219, 238 )"}
};
case WindowTheme::Dark:
return {
{BUTTONS_BASE,
"rgb( 10, 155, 10 )"},
{BUTTONS_BASE_HOVER,
"rgb( 33, 162, 33 )"},
{BUTTONS_BASE_FLAT,
"rgb( 21, 71, 21 )"},
{BUTTONS_BASE_DISABLED,
"rgb( 21, 71, 21 )"}
};
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
}
}
QString makeStyleSheet()
{
const StyleMap style{ makeStyleMap() };
return
"QPushButton {"
" border: 0px;"
" border-radius: 8px;"
" padding-left: 4px;"
" padding-right: 4px;"
" background-color: "+style.at(BUTTONS_BASE)+";"
"}"
"QPushButton:hover {"
" background-color: "+style.at(BUTTONS_BASE_HOVER)+";"
"}"
"QPushButton::flat {"
" background-color: "+style.at(BUTTONS_BASE_FLAT)+";"
"}"
"QPushButton::disabled {"
" background-color: "+style.at(BUTTONS_BASE_DISABLED)+";"
"}";
}

View File

@ -29,7 +29,8 @@ namespace /*private*/
/*!
\param query Query instance from the target database
\return Whether the database is valid or not
\throw LogDoctorException, MakeNewDatabase
\throw VoidException
\throw MakeNewDatabase
\see checkCollectionDatabase(), checkHashesDatabase(), newCollectionDatabase(), newHashesDatabase()
*/
bool checkDatabaseTablesNames( QueryWrapper query )
@ -123,7 +124,7 @@ bool newCollectionDatabase( DatabaseWrapper db, const std::string& db_path, cons
db.name(),
QStringLiteral(R"(CREATE TABLE "%1" (...))").arg( ws_name ),
query->lastError().text() );
throw LogDoctorException{};
throw VoidException{};
}
}
@ -168,7 +169,7 @@ bool newHashesDatabase( DatabaseWrapper db, const std::string& db_path, const st
db.name(),
QStringLiteral(R"(CREATE TABLE "%1" (...))").arg( ws_name ),
query->lastError().text() );
throw LogDoctorException{};
throw VoidException{};
}
}
@ -322,7 +323,7 @@ bool checkCollectionDatabase( const std::string& db_path ) noexcept
}
return newCollectionDatabase( DatabaseHandler::get( DatabaseType::Data ), db_path, ws_names );
} catch (const LogDoctorException&) {
} catch (const VoidException&) {
return false;
}
@ -415,7 +416,7 @@ bool checkHashesDatabase( const std::string& db_path ) noexcept
}
return newHashesDatabase( DatabaseHandler::get( DatabaseType::Hashes ), db_path, ws_names );
} catch (const LogDoctorException&) {
} catch (const VoidException&) {
return false;
}

View File

@ -106,7 +106,7 @@ void applyChartTheme( const std::unordered_map<std::string, QFont>& fonts, QChar
break;
default:
// shouldn't be here
throw GenericException( "Unexpeced ChartsTheme ID: "+std::to_string(static_cast<themes_t>(GlobalConfigs::charts_theme)), true );
throw DoNotCatchException( "Unexpeced ChartsTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::charts_theme)) );
break;
}
axis_pen.setWidthF( 1.1 );

View File

@ -28,8 +28,9 @@ std::unordered_map<ColorsScheme, std::unordered_map<std::string, QString>> getCo
//! Applies the choosen theme to the given chart
/*!
\param fonts The fonts set
\param chart_view The chart on which the theme will be applied
\param fonts The fonts set
\param chart_view The chart on which the theme will be applied
\throw DoNotCatchException
*/
void applyChartTheme( const std::unordered_map<std::string, QFont>& fonts, QChartView* chart_view );

View File

@ -31,7 +31,7 @@ size_t availableMemory() {
mach_msg_type_number_t count{ HOST_VM_INFO_COUNT };
vm_statistics_data_t vmstat;
if ( host_statistics( mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count ) != KERN_SUCCESS ) {
throw GenericException("Failed to get host infos", true);
throw DoNotCatchException("Failed to get host infos",);
}
const natural_t n_pages{ vmstat.free_count };
const long page_size{ sysconf( _SC_PAGE_SIZE ) };
@ -45,10 +45,10 @@ size_t availableMemory() {
size_t vmt_size{ sizeof(vmt) };
size_t uint_size{ sizeof(page_size) };
if ( sysctlbyname("vm.vmtotal", &vmt, &vmt_size, NULL, 0) < 0 ) {
throw GenericException("Failed to get vmtotal", true);
throw DoNotCatchException("Failed to get vmtotal");
}
if ( sysctlbyname("vm.stats.vm.v_page_size", &page_size, &uint_size, NULL, 0) < 0 ) {
throw GenericException("Failed to get v_page_size", true);
throw DoNotCatchException("Failed to get v_page_size");
}
return vmt.t_free * static_cast<size_t>( page_size );
#elif defined( Q_OS_UNIX )

View File

@ -14,6 +14,7 @@ namespace{ using size_t = unsigned long; }
//! Returns the available (free) memory in the system
/*!
\return The amount of memory in Bytes
\throw DoNotCatchException
*/
size_t availableMemory();

View File

@ -11,9 +11,6 @@
#include <unordered_map>
namespace /*private*/
{
enum StyleId : uint32_t {
TEXT_PRIMARY,
TEXT_DISABLED,
@ -421,13 +418,11 @@ StyleMap makeStyleMap()
};
break;
default:
throw GenericException( "Unexpected WindowTheme: "+std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)), true );
throw DoNotCatchException( "Unexpected WindowTheme", std::to_string(static_cast<themes_t>(GlobalConfigs::window_theme)) );
break;
}
}
} // namespace (private)
namespace StyleSec
{

View File

@ -12,9 +12,9 @@ class QString;
namespace StyleSec
{
//! Provides the requested stylesheet
//! Returns the proper style sheet
/*!
\return The stylesheet string
\throw DoNotCatchException
*/
QString getStyleSheet();