|
|
|
|
@ -37,15 +37,19 @@ def get_db():
|
|
|
|
|
def _db_error_detail(exc: SQLAlchemyError) -> str:
|
|
|
|
|
text = str(exc).lower()
|
|
|
|
|
|
|
|
|
|
# Heuristica para identificar falhas no MySQL de tools.
|
|
|
|
|
tools_markers = ("tools", "tool")
|
|
|
|
|
if any(marker in text for marker in tools_markers):
|
|
|
|
|
return "Servico temporariamente indisponivel: banco MySQL (tools) inacessivel."
|
|
|
|
|
|
|
|
|
|
# Heuristica para identificar falhas no MySQL (base ficticia).
|
|
|
|
|
mysql_markers = ("mysql", "pymysql", "(2003", "mock", "3306")
|
|
|
|
|
if any(marker in text for marker in mysql_markers):
|
|
|
|
|
mysql_mock_markers = ("mock", "vehicles", "customers", "orders", "review_schedules")
|
|
|
|
|
if any(marker in text for marker in mysql_mock_markers):
|
|
|
|
|
return "Servico temporariamente indisponivel: banco MySQL (dados ficticios) inacessivel."
|
|
|
|
|
|
|
|
|
|
# Heuristica para identificar falhas no PostgreSQL (tools).
|
|
|
|
|
pg_markers = ("postgres", "psycopg", "postgresql", "5432", "tools")
|
|
|
|
|
if any(marker in text for marker in pg_markers):
|
|
|
|
|
return "Servico temporariamente indisponivel: banco PostgreSQL (tools) inacessivel."
|
|
|
|
|
mysql_generic_markers = ("mysql", "pymysql", "(2003", "3306")
|
|
|
|
|
if any(marker in text for marker in mysql_generic_markers):
|
|
|
|
|
return "Servico temporariamente indisponivel: banco MySQL inacessivel."
|
|
|
|
|
|
|
|
|
|
return "Servico temporariamente indisponivel: erro de acesso ao banco de dados."
|
|
|
|
|
|
|
|
|
|
|