1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/include/villas/node/exceptions.hpp

76 lines
1.3 KiB
C++
Raw Normal View History

2019-03-26 07:11:27 +01:00
/** VILLASnode exceptions.
*
* @file
* @author Steffen Vogel <post@steffenvogel.de>
2022-03-15 09:28:57 -04:00
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
2022-07-04 18:20:03 +02:00
* @license Apache 2.0
2019-03-26 07:11:27 +01:00
*********************************************************************************/
#pragma once
#include <villas/node/config.hpp>
2019-03-26 07:11:27 +01:00
#include <villas/exceptions.hpp>
2019-04-23 10:05:06 +02:00
#ifdef WITH_CONFIG
#include <libconfig.h>
#endif
2019-03-26 07:11:27 +01:00
namespace villas {
namespace node {
class ParseError : public RuntimeError {
protected:
std::string text;
std::string file;
int line;
int column;
public:
ParseError(const std::string &t, const std::string &f, int l, int c = 0) :
RuntimeError("Failed to parse configuration: {} in {}:{}", t, f, l),
text(t),
file(f),
line(l),
column(c)
{ }
};
2019-04-05 11:01:49 +02:00
#ifdef WITH_CONFIG
2019-03-26 07:11:27 +01:00
class LibconfigParseError : public ParseError {
protected:
const config_t *config;
public:
LibconfigParseError(const config_t *c) :
ParseError(
config_error_text(c),
config_error_file(c) ? config_error_file(c) : "<unknown>",
config_error_line(c)
),
config(c)
{ }
};
2019-04-05 11:01:49 +02:00
#endif /* WITH_CONFIG */
2019-03-26 07:11:27 +01:00
class JanssonParseError : public ParseError {
protected:
json_error_t error;
public:
JanssonParseError(json_error_t e) :
ParseError(
e.text,
e.source,
e.line,
e.column
),
error(e)
{ }
};
2020-06-15 22:16:38 +02:00
} /* namespace node */
} /* namespace villas */