Skip to content

Commit

Permalink
fix: message bar when connection refused
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Nov 15, 2024
1 parent af23aec commit 7ca8534
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ def _on_movetool_map_release(self, point, idx):
self.moved_idxs -= 1
else:
raise e
except Exception as e:
if "Connection refused" in str(e):
self.api_key_message_bar()
else:
raise e

else:
try:
Expand All @@ -755,6 +760,11 @@ def _on_movetool_map_release(self, point, idx):
self.radius_message_box()
else:
raise e
except Exception as e:
if "Connection refused" in str(e):
self.api_key_message_bar()
else:
raise e

def create_rubber_band(self):
if self.rubber_band:
Expand Down Expand Up @@ -881,6 +891,12 @@ def _toggle_preview(self):
self.radius_message_box()
else:
raise e
except Exception as e:
self.toggle_preview.setChecked(not state)
if "Connection refused" in str(e):
self.api_key_message_bar()
else:
raise e

def get_error_code(self, e):
json_start_index = e.message.find("{")
Expand All @@ -897,3 +913,11 @@ def radius_message_box(self):
level=Qgis.MessageLevel.Warning,
duration=3,
)

def api_key_message_bar(self):
self._iface.messageBar().pushMessage(
"Connection refused",
"""Are your provider settings correct and the provider ready?""",
level=Qgis.MessageLevel.Warning,
duration=3,
)

0 comments on commit 7ca8534

Please sign in to comment.