Skip to content

Commit

Permalink
Use method-level rescues for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
Empact committed Aug 14, 2011
1 parent 67d0a74 commit 2f39602
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
8 changes: 3 additions & 5 deletions lib/spatial_adapter/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ class SpatialMysqlColumn < MysqlColumn
#MySql-specific geometry string parsing. By default, MySql returns geometries in strict wkb format with "0" characters in the first 4 positions.
def self.string_to_geometry(string)
return string unless string.is_a?(String)
begin
GeoRuby::SimpleFeatures::Geometry.from_ewkb(string[4..-1])
rescue Exception => exception
nil
end
GeoRuby::SimpleFeatures::Geometry.from_ewkb(string[4..-1])
rescue Exception => exception
nil
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions lib/spatial_adapter/mysql2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ class SpatialMysql2Column < Mysql2Column
#MySql-specific geometry string parsing. By default, MySql returns geometries in strict wkb format with "0" characters in the first 4 positions.
def self.string_to_geometry(string)
return string unless string.is_a?(String)
begin
GeoRuby::SimpleFeatures::Geometry.from_ewkb(string[4..-1])
rescue Exception => exception
nil
end
GeoRuby::SimpleFeatures::Geometry.from_ewkb(string[4..-1])
rescue Exception => exception
nil
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions lib/spatial_adapter/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
include SpatialAdapter

def postgis_version
begin
select_value("SELECT postgis_full_version()").scan(/POSTGIS="([\d\.]*)"/)[0][0]
rescue ActiveRecord::StatementInvalid
nil
end
select_value("SELECT postgis_full_version()").scan(/POSTGIS="([\d\.]*)"/)[0][0]
rescue ActiveRecord::StatementInvalid
nil
end

def postgis_major_version
Expand Down

0 comments on commit 2f39602

Please sign in to comment.