]> git.giorgioravera.it Git - network-manager.git/commitdiff
Fixed HTTPException
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 16 Mar 2026 20:25:12 +0000 (21:25 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 16 Mar 2026 20:25:12 +0000 (21:25 +0100)
backend/routes/aliases.py
backend/routes/backup.py
backend/routes/dhcp.py
backend/routes/dns.py
backend/routes/hosts.py

index ae70cd7276d0e3618718371bd931c154407c3303..b97da40ce326a2eb5418518c06d9d9f5c63ef7fa 100644 (file)
@@ -51,6 +51,9 @@ def api_get_aliases(request: Request):
         aliases = get_aliases()
         return aliases or []
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error getting list alias %s", str(err).strip())
         raise HTTPException(
@@ -86,6 +89,9 @@ def api_get_alias(request: Request, alias_id: int):
             )
         return alias
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error adding alias %s: %s", alias_id, str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
@@ -139,8 +145,8 @@ def api_add_alias(request: Request, data: dict):
             },
         )
 
-    except HTTPException as httpe:
-        raise httpe
+    except HTTPException:
+        raise
 
     except Exception as err:
         logger.exception("Error adding alias: %s", str(err).strip())
@@ -196,6 +202,9 @@ def api_update_alias(request: Request, data: dict, alias_id: int):
             },
         )
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error updating alias %s: %s", alias_id, str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
@@ -250,6 +259,9 @@ def api_delete_alias(request: Request, alias_id: int):
             },
         )
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error deleting alias %s: %s", alias_id, str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
index 0e8986cbc365c917b8c377f9ce42da4595670bdb..794f852425020117d4bf35800b8f568f3ef3017e 100644 (file)
@@ -31,7 +31,7 @@ def save_host():
     hosts = get_hosts()
 
     # Backup Hosts DB
-    path = settings.DATA_PATH + "/hosts.json"
+    path = os.path.join(settings.DATA_PATH, "hosts.json")
     with open(path, "w", encoding="utf-8") as f:
         for h in hosts:
             f.write(json.dumps(h, ensure_ascii=False) + "\n")
@@ -44,7 +44,7 @@ def save_aliases():
     aliases = get_aliases()
 
     # Backup Aliases DB
-    path = settings.DATA_PATH + "/aliases.json"
+    path = os.path.join(settings.DATA_PATH, "aliases.json")
     with open(path, "w", encoding="utf-8") as f:
         for a in aliases:
             f.write(json.dumps(a, ensure_ascii=False) + "\n")
@@ -56,7 +56,7 @@ def save_aliases():
     200: {"description": "Backup executed successfully"},
     500: {"description": "Internal server error"},
 })
-async def api_dns_reload(request: Request):
+async def api_backup(request: Request):
 
     # Inizializzazioni
     start_ns = time.monotonic_ns()
@@ -79,6 +79,9 @@ async def api_dns_reload(request: Request):
             },
         )
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
         logger.exception("Error executing backup: %s", str(err).strip())
index 5e0f33013216c2fd7d9ace88a7f2fc50116f24d2..df1c4178ff66d65c057849a6c1fffe2369c95619 100644 (file)
@@ -86,6 +86,9 @@ async def api_dhcp_reload(request: Request):
             },
         )
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error reloading DHCP: %s", str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
index cf7b12746e5ef7b650bdbb839671eaabc28f86a9..894e9c85412c122ca8cd2c372ca65041376f5e97 100644 (file)
@@ -124,6 +124,9 @@ async def api_dns_reload(request: Request):
             },
         )
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error reloading DNS: %s", str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
index c32b59469a4dc45e7a934a9b5d8a2351793113d9..06dd294641b9e07cdc2c0469024bf5cadd03f0b0 100644 (file)
@@ -51,6 +51,9 @@ def api_get_hosts(request: Request):
         hosts = get_hosts()
         return hosts or []
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error getting list host %s", str(err).strip())
         raise HTTPException(
@@ -86,6 +89,9 @@ def api_get_host(request: Request, host_id: int):
             )
         return host
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error adding host %s: %s", host_id, str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
@@ -139,8 +145,8 @@ def api_add_host(request: Request, data: dict):
             },
         )
 
-    except HTTPException as httpe:
-        raise httpe
+    except HTTPException:
+        raise
 
     except Exception as err:
         logger.exception("Error adding host: %s", str(err).strip())
@@ -196,6 +202,9 @@ def api_update_host(request: Request, data: dict, host_id: int):
             },
         )
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error updating host %s: %s", host_id, str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000
@@ -250,6 +259,9 @@ def api_delete_host(request: Request, host_id: int):
             },
         )
 
+    except HTTPException:
+        raise
+
     except Exception as err:
         logger.exception("Error deleting host %s: %s", host_id, str(err).strip())
         took_ms = (time.monotonic_ns() - start_ns) / 1_000_000