Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-3790 Provide namespace on UnknownSchemaError raise #2409

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lang/ruby/lib/avro/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def self.real_parse(json_obj, names=nil, default_namespace=nil)
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

Expand Down Expand Up @@ -621,9 +621,11 @@ class SchemaParseError < AvroError; end

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
Expand Down
2 changes: 2 additions & 0 deletions lang/ruby/test/test_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def test_unknown_named_type
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
Expand Down