Skip to content

Commit

Permalink
Import and use axiosError
Browse files Browse the repository at this point in the history
  • Loading branch information
weitheng01 committed Jan 28, 2025
1 parent 08f97c3 commit b8c9363
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions web/src/pages/FaceLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import useOptimisticState from "@/hooks/use-optimistic-state";
import { cn } from "@/lib/utils";
import { FrigateConfig } from "@/types/frigateConfig";
import axios from "axios";
import axios, { AxiosError } from "axios";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { LuImagePlus, LuTrash2, LuUserPlus, LuEdit } from "react-icons/lu";
import { toast } from "sonner";
Expand Down Expand Up @@ -150,8 +150,9 @@ export default function FaceLibrary() {
toast.success("Successfully created new face", { position: "top-center" });
}
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;
toast.error(
`Failed to create face: ${error.response?.data?.message || error.message}`,
`Failed to create face: ${axiosError.response?.data?.message || axiosError.message}`,
{ position: "top-center" }
);
} finally {
Expand Down Expand Up @@ -195,8 +196,9 @@ export default function FaceLibrary() {
refreshFaces();
toast.success("Successfully renamed face", { position: "top-center" });
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;
toast.error(
`Failed to rename face: ${error.response?.data?.message || error.message}`,
`Failed to rename face: ${axiosError.response?.data?.message || axiosError.message}`,
{ position: "top-center" }
);
} finally {
Expand Down

0 comments on commit b8c9363

Please sign in to comment.