[jira] [Commented] (AVRO-2113) Improve unexpected type error message

2018-04-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/AVRO-2113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16424080#comment-16424080
 ] 

ASF GitHub Bot commented on AVRO-2113:
--

thiru-apache closed pull request #305: AVRO-2113 Fixed error reporting in C++ 
schema parsing
URL: https://github.com/apache/avro/pull/305
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/CHANGES.txt b/CHANGES.txt
index faea72cfd..41d0a2ef2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -113,6 +113,8 @@ Trunk (not yet released)
 
 AVRO-2133: Log rat failures (gabor)
 
+AVRO-2113: Improve unexpected type error message (thiru)
+
   BUG FIXES
 
 AVRO-1741: Python3: Fix error when codec is not in the header.
diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt
index be3921521..8919fc38a 100644
--- a/lang/c++/CMakeLists.txt
+++ b/lang/c++/CMakeLists.txt
@@ -20,6 +20,8 @@ cmake_minimum_required (VERSION 2.6)
 
 set (CMAKE_LEGACY_CYGWIN_WIN32 0)
 
+cmake_policy (SET CMP0042 NEW)
+
 if (NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
 set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
 endif()
diff --git a/lang/c++/impl/Compiler.cc b/lang/c++/impl/Compiler.cc
index be5fe3f86..1252a717f 100644
--- a/lang/c++/impl/Compiler.cc
+++ b/lang/c++/impl/Compiler.cc
@@ -156,7 +156,9 @@ static void assertType(const Entity& e, EntityType et)
 {
 if (e.type() != et) {
 throw Exception(boost::format("Unexpected type for default value: "
-"Expected %1%, but found %2%") % et % e.type());
+"Expected %1%, but found %2% in line %3%") %
+json::typeToString(et) % json::typeToString(e.type()) %
+e.line());
 }
 }
 
@@ -205,8 +207,8 @@ static string nameof(const NodePtr& n)
 }
 }
 
-static GenericDatum makeGenericDatum(NodePtr n, const Entity& e,
-const SymbolTable& st)
+static GenericDatum makeGenericDatum(NodePtr n,
+const Entity& e, const SymbolTable& st)
 {
 Type t = n->type();
 if (t == AVRO_SYMBOLIC) {
diff --git a/lang/c++/impl/json/JsonDom.cc b/lang/c++/impl/json/JsonDom.cc
index 3f52f363b..f8174dbc7 100644
--- a/lang/c++/impl/json/JsonDom.cc
+++ b/lang/c++/impl/json/JsonDom.cc
@@ -31,7 +31,7 @@ using boost::format;
 
 namespace avro {
 namespace json {
-static const char* typeToString(EntityType t)
+const char* typeToString(EntityType t)
 {
 switch (t) {
 case etNull: return "null";
@@ -50,31 +50,33 @@ Entity readEntity(JsonParser& p)
 switch (p.peek()) {
 case JsonParser::tkNull:
 p.advance();
-return Entity();
+return Entity(p.line());
 case JsonParser::tkBool:
 p.advance();
-return Entity(p.boolValue());
+return Entity(p.boolValue(), p.line());
 case JsonParser::tkLong:
 p.advance();
-return Entity(p.longValue());
+return Entity(p.longValue(), p.line());
 case JsonParser::tkDouble:
 p.advance();
-return Entity(p.doubleValue());
+return Entity(p.doubleValue(), p.line());
 case JsonParser::tkString:
 p.advance();
-return Entity(boost::make_shared(p.stringValue()));
+return Entity(boost::make_shared(p.stringValue()), p.line());
 case JsonParser::tkArrayStart:
 {
+size_t l = p.line();
 p.advance();
 boost::shared_ptr v = boost::make_shared();
 while (p.peek() != JsonParser::tkArrayEnd) {
 v->push_back(readEntity(p));
 }
 p.advance();
-return Entity(v);
+return Entity(v, l);
 }
 case JsonParser::tkObjectStart:
 {
+size_t l = p.line();
 p.advance();
 boost::shared_ptr v = boost::make_shared();
 while (p.peek() != JsonParser::tkObjectEnd) {
@@ -84,7 +86,7 @@ Entity readEntity(JsonParser& p)
 v->insert(std::make_pair(k, n));
 }
 p.advance();
-return Entity(v);
+return Entity(v, l);
 }
 default:
 throw std::domain_error(JsonParser::toString(p.peek()));
diff --git a/lang/c++/impl/json/JsonDom.hh b/lang/c++/impl/json/JsonDom.hh
index 7de4fbcde..bde3b8f2c 100644
--- a/lang/c++/impl/json/JsonDom.hh
+++ b/lang/c++/impl/json/JsonDom.hh
@@ -59,21 +59,27 @@ enum EntityType {
 etObject
 };
 
+const char* typeToString(EntityType t);
+
 class AVRO_DECL Entity {
 EntityType type_;
 boost::any value_;
+const size_t line_;
+
 void ensureType(EntityType) const;
 public:
-Entity() : type_(etNull) { }
-Entity(Bool v) : type_(etBool), value_(v) { }
-Entity(Long v) : type_(etLong), value_(v) { }
-

[jira] [Commented] (AVRO-2113) Improve unexpected type error message

2018-04-03 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/AVRO-2113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16424081#comment-16424081
 ] 

ASF subversion and git services commented on AVRO-2113:
---

Commit 3b6658dfcfea85e140420de207fb29d583a6df0e in avro's branch 
refs/heads/master from Thiruvalluvan M G
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=3b6658d ]

Merge pull request #305 from thiru-apache/AVRO-2113

AVRO-2113 Fixed error reporting in C++ schema parsing

> Improve unexpected type error message
> -
>
> Key: AVRO-2113
> URL: https://issues.apache.org/jira/browse/AVRO-2113
> Project: Avro
>  Issue Type: Improvement
>  Components: c++
>Reporter: Victor Mota
>Assignee: Thiruvalluvan M. G.
>Priority: Minor
> Fix For: 1.8.3
>
>
> Currently the error message for default type mismatch is not very user 
> friendly:
> https://github.com/apache/avro/blob/17f2d75132021fafeca29edbdcade40df960fdc9/lang/c%2B%2B/impl/Compiler.cc#L158
> ie. "Unexpected type for default value: Expected 3, but found 2". Specifying 
> the field where this is happening and what the types mismatched are in human 
> readable format (ie. string, etc) would benefit the user a lot in debugging.
> Here is an example of a user having issues understanding the error: 
> https://issuetracker.google.com/issues/70351564.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AVRO-2113) Improve unexpected type error message

2018-04-03 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/AVRO-2113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16424082#comment-16424082
 ] 

ASF subversion and git services commented on AVRO-2113:
---

Commit 3b6658dfcfea85e140420de207fb29d583a6df0e in avro's branch 
refs/heads/master from Thiruvalluvan M G
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=3b6658d ]

Merge pull request #305 from thiru-apache/AVRO-2113

AVRO-2113 Fixed error reporting in C++ schema parsing

> Improve unexpected type error message
> -
>
> Key: AVRO-2113
> URL: https://issues.apache.org/jira/browse/AVRO-2113
> Project: Avro
>  Issue Type: Improvement
>  Components: c++
>Reporter: Victor Mota
>Assignee: Thiruvalluvan M. G.
>Priority: Minor
> Fix For: 1.8.3
>
>
> Currently the error message for default type mismatch is not very user 
> friendly:
> https://github.com/apache/avro/blob/17f2d75132021fafeca29edbdcade40df960fdc9/lang/c%2B%2B/impl/Compiler.cc#L158
> ie. "Unexpected type for default value: Expected 3, but found 2". Specifying 
> the field where this is happening and what the types mismatched are in human 
> readable format (ie. string, etc) would benefit the user a lot in debugging.
> Here is an example of a user having issues understanding the error: 
> https://issuetracker.google.com/issues/70351564.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AVRO-2113) Improve unexpected type error message

2018-04-01 Thread Thiruvalluvan M. G. (JIRA)

[ 
https://issues.apache.org/jira/browse/AVRO-2113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16421735#comment-16421735
 ] 

Thiruvalluvan M. G. commented on AVRO-2113:
---

Made a pull request: [https://github.com/apache/avro/pull/305.] If there are no 
objections, I'll merge it in a couple of days.

> Improve unexpected type error message
> -
>
> Key: AVRO-2113
> URL: https://issues.apache.org/jira/browse/AVRO-2113
> Project: Avro
>  Issue Type: Improvement
>  Components: c++
>Reporter: Victor Mota
>Assignee: Thiruvalluvan M. G.
>Priority: Minor
>
> Currently the error message for default type mismatch is not very user 
> friendly:
> https://github.com/apache/avro/blob/17f2d75132021fafeca29edbdcade40df960fdc9/lang/c%2B%2B/impl/Compiler.cc#L158
> ie. "Unexpected type for default value: Expected 3, but found 2". Specifying 
> the field where this is happening and what the types mismatched are in human 
> readable format (ie. string, etc) would benefit the user a lot in debugging.
> Here is an example of a user having issues understanding the error: 
> https://issuetracker.google.com/issues/70351564.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AVRO-2113) Improve unexpected type error message

2017-12-08 Thread Benjamin Schleimer (JIRA)

[ 
https://issues.apache.org/jira/browse/AVRO-2113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16283988#comment-16283988
 ] 

Benjamin Schleimer commented on AVRO-2113:
--

This is an issue for my team as yet. The message should be more verbose about 
the type mismatch

> Improve unexpected type error message
> -
>
> Key: AVRO-2113
> URL: https://issues.apache.org/jira/browse/AVRO-2113
> Project: Avro
>  Issue Type: Improvement
>  Components: c++
>Reporter: Victor Mota
>Priority: Minor
>
> Currently the error message for default type mismatch is not very user 
> friendly:
> https://github.com/apache/avro/blob/17f2d75132021fafeca29edbdcade40df960fdc9/lang/c%2B%2B/impl/Compiler.cc#L158
> ie. "Unexpected type for default value: Expected 3, but found 2". Specifying 
> the field where this is happening and what the types mismatched are in human 
> readable format (ie. string, etc) would benefit the user a lot in debugging.
> Here is an example of a user having issues understanding the error: 
> https://issuetracker.google.com/issues/70351564.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)