mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
conky_error class replacing runtime_error
This commit is contained in:
parent
fbec1252a1
commit
5dd486d345
@ -2646,7 +2646,7 @@ void load_config_file()
|
||||
l.getfield(-1, "text");
|
||||
l.replace(-2);
|
||||
if(l.type(-1) != lua::TSTRING)
|
||||
throw std::runtime_error("missing text block in configuration; exiting");
|
||||
throw conky_error(critical, "missing text block in configuration; exiting");
|
||||
|
||||
/* Remove \\-\n. */
|
||||
l.gsub(l.tocstring(-1), "\\\n", "");
|
||||
@ -3053,8 +3053,9 @@ int main(int argc, char **argv)
|
||||
first_pass = 0; /* don't ever call fork() again */
|
||||
|
||||
}
|
||||
catch(std::exception &e) {
|
||||
catch(conky_error &e) {
|
||||
std::cerr << "caught exception: " << e.what() << std::endl;
|
||||
if(e.errortype() == critical) exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef BUILD_WEATHER_XOAP
|
||||
|
@ -31,6 +31,7 @@
|
||||
#define _LOGGING_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <stdexcept>
|
||||
#include "i18n.h"
|
||||
|
||||
void clean_up(void *memtofree1, void* memtofree2);
|
||||
@ -58,6 +59,18 @@ inline void gettextize_format(const char *format)
|
||||
#define THREAD_CRIT_ERR(memtofree1, memtofree2, ...) \
|
||||
{ NORM_ERR(__VA_ARGS__); clean_up_without_threads(memtofree1, memtofree2); return; }
|
||||
|
||||
enum error_type { normal, critical };
|
||||
class conky_error : public std::runtime_error {
|
||||
error_type type;
|
||||
public:
|
||||
conky_error(error_type newtype, const std::string& error_mesg) : std::runtime_error(error_mesg) {
|
||||
type = newtype;
|
||||
}
|
||||
error_type errortype() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
/* debugging output */
|
||||
extern int global_debug_level;
|
||||
#define __DBGP(level, ...) do {\
|
||||
|
Loading…
Reference in New Issue
Block a user