refactor: enhance Overpass API handling with multiple endpoints and improved error reporting
This commit is contained in:
1 parent
33be95ef59
commit
efddc55ad0
2 files changed
+29
-5
No files matched your search
@@ -65,8 +65,13 @@ module Maptool
|
||||
south, west, north, east = bbox
|
||||
args = ["--south=#{south}", "--west=#{west}", "--north=#{north}", "--east=#{east}"]
|
||||
|
||||
stdout, _stderr, status = Open3.capture3(command, *args, chdir: plugin_dir)
|
||||
raise RunError, "plugin exited with status #{status.exitstatus}" unless status.success?
|
||||
stdout, stderr, status = Open3.capture3(command, *args, chdir: plugin_dir)
|
||||
# First stderr line too — for a Ruby plugin that's the exception
|
||||
# message (e.g. "...: unexpected response 406"), the only clue to why.
|
||||
unless status.success?
|
||||
reason = stderr.lines.first&.strip
|
||||
raise RunError, ["plugin exited with status #{status.exitstatus}", reason].compact.reject(&:empty?).join(": ")
|
||||
end
|
||||
|
||||
geojson = JSON.parse(stdout)
|
||||
raise RunError, "plugin did not print a GeoJSON FeatureCollection" unless geojson.is_a?(Hash) && geojson["type"] == "FeatureCollection"
|
||||
|
||||
Reference in new issue
Block a user