From 6045a6d15738b3104e34cc05a9c5624f3f98bd03 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 27 Jun 2022 15:13:59 +0200 Subject: Support more verbose error reporting --- src/buildtool/build_engine/expression/evaluator.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/buildtool/build_engine/expression/evaluator.hpp') diff --git a/src/buildtool/build_engine/expression/evaluator.hpp b/src/buildtool/build_engine/expression/evaluator.hpp index b4cd5979..e709de43 100644 --- a/src/buildtool/build_engine/expression/evaluator.hpp +++ b/src/buildtool/build_engine/expression/evaluator.hpp @@ -10,7 +10,17 @@ class Configuration; class Evaluator { + struct ConfigData { + std::size_t expression_log_limit{kDefaultExpressionLogLimit}; + }; + public: + /// \brief Set the limit for the size of logging a single expression + /// in an error message. + static void SetExpressionLogLimit(std::size_t width) { + Config().expression_log_limit = width; + } + class EvaluationError : public std::exception { public: explicit EvaluationError(std::string const& msg, @@ -65,12 +75,17 @@ class Evaluator { std::function const& note_user_context = []() {}) noexcept -> ExpressionPtr; + constexpr static std::size_t kDefaultExpressionLogLimit = 320; + private: - constexpr static std::size_t kLineWidth = 80; [[nodiscard]] static auto Evaluate(ExpressionPtr const& expr, Configuration const& env, FunctionMapPtr const& functions) -> ExpressionPtr; + [[nodiscard]] static auto Config() noexcept -> ConfigData& { + static ConfigData instance{}; + return instance; + } }; #endif // INCLUDED_SRC_BUILDTOOL_BUILD_ENGINE_EXPRESSION_EVALUATOR_HPP -- cgit v1.2.3