This is an automated email from the ASF dual-hosted git repository.
tjwp pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/branch-1.11 by this push:
new 0a0cd1e3f AVRO-3790: [Ruby] Provide namespace on UnknownSchemaError
raise (#2409)
0a0cd1e3f is described below
commit 0a0cd1e3fc77d2723deadc9c9e5c750191484ddf
Author: Rémi Piotaix <[email protected]>
AuthorDate: Tue Aug 8 18:49:07 2023 +0200
AVRO-3790: [Ruby] Provide namespace on UnknownSchemaError raise (#2409)
---
lang/ruby/lib/avro/schema.rb | 6 ++++--
lang/ruby/test/test_schema.rb | 2 ++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lang/ruby/lib/avro/schema.rb b/lang/ruby/lib/avro/schema.rb
index 444911de5..37e1d2103 100644
--- a/lang/ruby/lib/avro/schema.rb
+++ b/lang/ruby/lib/avro/schema.rb
@@ -111,7 +111,7 @@ module Avro
elsif PRIMITIVE_TYPES.include? json_obj
return PrimitiveSchema.new(json_obj)
else
- raise UnknownSchemaError.new(json_obj)
+ raise UnknownSchemaError.new(json_obj, default_namespace)
end
end
@@ -621,9 +621,11 @@ module Avro
class UnknownSchemaError < SchemaParseError
attr_reader :type_name
+ attr_reader :default_namespace
- def initialize(type)
+ def initialize(type, default_namespace)
@type_name = type
+ @default_namespace = default_namespace
super("#{type.inspect} is not a schema we know about.")
end
end
diff --git a/lang/ruby/test/test_schema.rb b/lang/ruby/test/test_schema.rb
index 258cd198c..182f7dd8b 100644
--- a/lang/ruby/test/test_schema.rb
+++ b/lang/ruby/test/test_schema.rb
@@ -176,6 +176,8 @@ class TestSchema < Test::Unit::TestCase
end
assert_equal '"MissingType" is not a schema we know about.', error.message
+ assert_equal "MissingType", error.type_name
+ assert_equal "my.name.space", error.default_namespace
end
def test_invalid_name