Merge pull request #2887 from tchak/fix-old-carto

Fix sentry errors in old carto module
This commit is contained in:
gregoirenovel 2018-10-22 21:46:07 +02:00 committed by GitHub
commit 744117537b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -65,9 +65,13 @@ class Users::CarteController < UsersController
# https://tools.ietf.org/html/rfc7946#section-3.1.6
if json_latlngs.present?
multipolygone = JSON.parse(json_latlngs)
multipolygone.reject! { |polygone| polygone.count < 4 }
if multipolygone.present?
multipolygone.to_json
if multipolygone.first == ["error", "TooManyPolygons"]
[].to_json
else
multipolygone.reject! { |polygone| polygone.count < 4 }
if multipolygone.present?
multipolygone.to_json
end
end
end
end

View file

@ -91,7 +91,7 @@ module ApplicationHelper
end
def ensure_safe_json(json)
JSON.parse(json).to_json
json.present? ? JSON.parse(json).to_json : '[]'
rescue Exception => e
Raven.capture_exception(e)
{}