You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2019/02/08 23:55:22 UTC

[trafficserver] branch master updated: Marks the YAML exceptions, which gives line number / pos info

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a32595  Marks the YAML exceptions, which gives line number / pos info
3a32595 is described below

commit 3a3259502090ca4bc76f27915ad91fadde782cc6
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri Feb 8 10:37:19 2019 -0700

    Marks the YAML exceptions, which gives line number / pos info
---
 iocore/net/YamlSNIConfig.cc            |  8 ++++----
 proxy/logging/YamlLogConfig.cc         | 14 +++++++-------
 proxy/logging/YamlLogConfigDecoders.cc |  8 ++++----
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/iocore/net/YamlSNIConfig.cc b/iocore/net/YamlSNIConfig.cc
index 84e118e..6ba226e 100644
--- a/iocore/net/YamlSNIConfig.cc
+++ b/iocore/net/YamlSNIConfig.cc
@@ -115,7 +115,7 @@ template <> struct convert<YamlSNIConfig::Item> {
     for (auto &&item : node) {
       if (std::none_of(valid_sni_config_keys.begin(), valid_sni_config_keys.end(),
                        [&item](std::string s) { return s == item.first.as<std::string>(); })) {
-        throw std::runtime_error("unsupported key " + item.first.as<std::string>());
+        throw YAML::ParserException(item.Mark(), "unsupported key " + item.first.as<std::string>());
       }
     }
 
@@ -133,7 +133,7 @@ template <> struct convert<YamlSNIConfig::Item> {
       auto value = node[TS_verify_client].as<std::string>();
       int level  = LEVEL_DESCRIPTOR.get(value);
       if (level < 0) {
-        throw std::runtime_error("unknown value \"" + value + "\"");
+        throw YAML::ParserException(node[TS_verify_client].Mark(), "unknown value \"" + value + "\"");
       }
       item.verify_client_level = static_cast<uint8_t>(level);
     }
@@ -169,7 +169,7 @@ template <> struct convert<YamlSNIConfig::Item> {
       auto value = node[TS_verify_server_policy].as<std::string>();
       int policy = POLICY_DESCRIPTOR.get(value);
       if (policy < 0) {
-        throw std::runtime_error("unknown value \"" + value + "\"");
+        throw YAML::ParserException(node[TS_verify_server_policy].Mark(), "unknown value \"" + value + "\"");
       }
       item.verify_server_policy = static_cast<YamlSNIConfig::Policy>(policy);
     }
@@ -178,7 +178,7 @@ template <> struct convert<YamlSNIConfig::Item> {
       auto value     = node[TS_verify_server_properties].as<std::string>();
       int properties = PROPERTIES_DESCRIPTOR.get(value);
       if (properties < 0) {
-        throw std::runtime_error("unknown value \"" + value + "\"");
+        throw YAML::ParserException(node[TS_verify_server_properties].Mark(), "unknown value \"" + value + "\"");
       }
       item.verify_server_properties = static_cast<YamlSNIConfig::Property>(properties);
     }
diff --git a/proxy/logging/YamlLogConfig.cc b/proxy/logging/YamlLogConfig.cc
index cc4c6ac..71bc8ef 100644
--- a/proxy/logging/YamlLogConfig.cc
+++ b/proxy/logging/YamlLogConfig.cc
@@ -111,17 +111,17 @@ YamlLogConfig::decodeLogObject(const YAML::Node &node)
   for (auto &&item : node) {
     if (std::none_of(valid_log_object_keys.begin(), valid_log_object_keys.end(),
                      [&item](std::string s) { return s == item.first.as<std::string>(); })) {
-      throw std::runtime_error("log: unsupported key '" + item.first.as<std::string>() + "'");
+      throw YAML::ParserException(item.Mark(), "log: unsupported key '" + item.first.as<std::string>() + "'");
     }
   }
 
   if (!node["format"]) {
-    throw std::runtime_error("missing 'format' argument");
+    throw YAML::ParserException(node.Mark(), "missing 'format' argument");
   }
   std::string format = node["format"].as<std::string>();
 
   if (!node["filename"]) {
-    throw std::runtime_error("missing 'filename' argument");
+    throw YAML::ParserException(node.Mark(), "missing 'filename' argument");
   }
 
   std::string header;
@@ -155,7 +155,7 @@ YamlLogConfig::decodeLogObject(const YAML::Node &node)
     auto value          = node["rolling_enabled"].as<std::string>();
     obj_rolling_enabled = ROLLING_MODE.get(value);
     if (obj_rolling_enabled < 0) {
-      throw std::runtime_error("unknown value " + value);
+      throw YAML::ParserException(node["rolling_enabled"].Mark(), "unknown value " + value);
     }
   }
   if (node["rolling_interval_sec"]) {
@@ -202,7 +202,7 @@ YamlLogConfig::decodeLogObject(const YAML::Node &node)
   }
 
   if (!filters.IsSequence()) {
-    throw std::runtime_error("'filters' should be a list");
+    throw YAML::ParserException(filters.Mark(), "'filters' should be a list");
   }
 
   for (auto &&filter : filters) {
@@ -221,7 +221,7 @@ YamlLogConfig::decodeLogObject(const YAML::Node &node)
   }
 
   if (!collation_host_list.IsSequence()) {
-    throw std::runtime_error("'collation_hosts' should be a list of collation_host objects");
+    throw YAML::ParserException(collation_host_list.Mark(), "'collation_hosts' should be a list of collation_host objects");
   }
 
   for (auto &&collation_host : collation_host_list) {
@@ -246,7 +246,7 @@ YamlLogConfig::decodeLogObject(const YAML::Node &node)
 
     if (!collation_host["failover"].IsSequence()) {
       delete lh;
-      throw std::runtime_error("'failover' should be a list of host names");
+      throw YAML::ParserException(collation_host["failover"].Mark(), "'failover' should be a list of host names");
     }
 
     LogHost *prev = lh;
diff --git a/proxy/logging/YamlLogConfigDecoders.cc b/proxy/logging/YamlLogConfigDecoders.cc
index d1853c1..6146aca 100644
--- a/proxy/logging/YamlLogConfigDecoders.cc
+++ b/proxy/logging/YamlLogConfigDecoders.cc
@@ -39,12 +39,12 @@ convert<std::unique_ptr<LogFormat>>::decode(const Node &node, std::unique_ptr<Lo
   for (auto &&item : node) {
     if (std::none_of(valid_log_format_keys.begin(), valid_log_format_keys.end(),
                      [&item](std::string s) { return s == item.first.as<std::string>(); })) {
-      throw std::runtime_error("format: unsupported key '" + item.first.as<std::string>() + "'");
+      throw YAML::ParserException(node.Mark(), "format: unsupported key '" + item.first.as<std::string>() + "'");
     }
   }
 
   if (!node["format"]) {
-    throw std::runtime_error("missing 'format' argument");
+    throw YAML::ParserException(node.Mark(), "missing 'format' argument");
   }
   std::string format = node["format"].as<std::string>();
 
@@ -80,14 +80,14 @@ convert<std::unique_ptr<LogFilter>>::decode(const Node &node, std::unique_ptr<Lo
   for (auto &&item : node) {
     if (std::none_of(valid_log_filter_keys.begin(), valid_log_filter_keys.end(),
                      [&item](std::string s) { return s == item.first.as<std::string>(); })) {
-      throw std::runtime_error("filter: unsupported key '" + item.first.as<std::string>() + "'");
+      throw YAML::ParserException(node.Mark(), "filter: unsupported key '" + item.first.as<std::string>() + "'");
     }
   }
 
   // we require all keys for LogFilter
   for (auto &&item : valid_log_filter_keys) {
     if (!node[item]) {
-      throw std::runtime_error("missing '" + item + "' argument");
+      throw YAML::ParserException(node.Mark(), "missing '" + item + "' argument");
     }
   }