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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.3 KiB
C++
Raw Permalink Normal View History

2019-03-26 07:11:27 +01:00
/* VILLASnode exceptions.
*
2022-03-15 09:18:01 -04:00
* Author: Steffen Vogel <post@steffenvogel.de>
2022-03-15 09:28:57 -04:00
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
2022-07-04 18:20:03 +02:00
* SPDX-License-Identifier: Apache-2.0
2019-03-26 07:11:27 +01:00
*/
#pragma once
#include <villas/exceptions.hpp>
#include <villas/node/config.hpp>
2019-03-26 07:11:27 +01:00
2019-04-23 10:05:06 +02:00
#ifdef WITH_CONFIG
#include <libconfig.h>
2019-04-23 10:05:06 +02:00
#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;
2019-03-26 07:11:27 +01:00
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-03-26 07:11:27 +01:00
};
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;
2019-03-26 07:11:27 +01:00
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-03-26 07:11:27 +01:00
};
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;
2019-03-26 07:11:27 +01:00
public:
JanssonParseError(json_error_t e)
: ParseError(e.text, e.source, e.line, e.column), error(e) {}
2019-03-26 07:11:27 +01:00
};
} // namespace node
} // namespace villas