Permalink
Browse files

Catch other places where Addressable::URI::InvalidURIError might be r…

…aised and transform to ArgumentError.
  • Loading branch information...
1 parent 2cd4bdc commit 43f3a42d3c56c0bc616ce5772b1284675f13cd7d @gkellogg gkellogg committed Apr 3, 2013
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/rdf/model/uri.rb
View
6 lib/rdf/model/uri.rb
@@ -138,6 +138,7 @@ def self.parse(str)
#
# @overload URI.new(options = {})
# @param [Hash{Symbol => Object}] options
+ # @raise [ArgumentError] on seriously invalid URI
def initialize(uri_or_options)
case uri_or_options
when Hash
@@ -147,6 +148,8 @@ def initialize(uri_or_options)
else
@uri = Addressable::URI.parse(uri_or_options.to_s)
end
+ rescue Addressable::URI::InvalidURIError => e
+ raise ArgumentError, e.message
end
##
@@ -357,8 +360,11 @@ def /(fragment)
# @see RDF::URI#join
# @param [Any] other
# @return [RDF::URI]
+ # @raise [ArgumentError] on seriously invalid URI
def +(other)
RDF::URI.intern(self.to_s + other.to_s)
+ rescue Addressable::URI::InvalidURIError => e
+ raise ArgumentError, e.message
end
##

0 comments on commit 43f3a42

Please sign in to comment.