2019-03-26 07:11:27 +01:00
|
|
|
/** VILLASnode exceptions.
|
|
|
|
*
|
|
|
|
* @file
|
2022-12-14 17:41:58 +01:00
|
|
|
* @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
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#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 */
|