Skip to content

Commit

Permalink
fix(site): Handle common exceptions during login_as_admin/team
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurali27 committed Jan 20, 2025
1 parent 460e652 commit 62f834a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions press/press/doctype/site/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,15 @@ def get_login_sid(self, user="Administrator"):
try:
agent = Agent(self.server)
sid = agent.get_site_sid(self, user)
except requests.HTTPError as e:
if "validate_ip_address" in str(e):
frappe.throw(
f"Login with {user}'s credentials is IP restricted. Please remove the same and try again.",
frappe.ValidationError,
)
elif f"User {user} does not exist" in str(e):
frappe.throw(f"User {user} does not exist in the site", frappe.ValidationError)
raise e
except AgentRequestSkippedException:
frappe.throw(
"Server is unresponsive. Please try again in some time.",
Expand Down

0 comments on commit 62f834a

Please sign in to comment.