improver error handling
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s

This commit is contained in:
2025-12-18 21:45:43 +01:00
parent 9afe49857a
commit a2a017f900
7 changed files with 52 additions and 38 deletions

View File

@@ -17,6 +17,22 @@ export const api = axios.create({
timeout: 10000,
});
// 🔹 Normalize FastAPI errors here
api.interceptors.response.use(
(response) => response,
(error) => {
// FastAPI HTTPException format
const detail =
error?.response?.data?.detail ??
error?.response?.data?.message ??
error.message ??
"Unknown error";
// Always reject with a standard Error
return Promise.reject(new Error(detail));
}
);
// Queries
export const fetchInterfaces = async (): Promise<InterfaceInfo[]> => {
const res = await api.get<InterfaceInfo[]>("/network/interfaces");