show error messages in flash message when wiping (#17245)

quick change to show the error message when wiping fails
This commit is contained in:
Gabriel Hernandez 2024-02-28 17:34:54 +00:00 committed by GitHub
parent 1710e1c8ef
commit 66f5c34288
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,12 +1,12 @@
import React, { useContext } from "react";
import hostAPI from "services/entities/hosts";
import { getErrorReason } from "interfaces/errors";
import Modal from "components/Modal";
import Button from "components/buttons/Button";
import Checkbox from "components/forms/fields/Checkbox";
import { NotificationContext } from "context/notification";
import { AxiosError } from "axios";
const baseClass = "wipe-modal";
@ -28,9 +28,8 @@ const WipeModal = ({ id, hostName, onSuccess, onClose }: IWipeModalProps) => {
await hostAPI.wipeHost(id);
onSuccess();
renderFlash("success", "Success! Host is wiping.");
} catch (error) {
const err = error as AxiosError;
renderFlash("error", err.message);
} catch (e) {
renderFlash("error", getErrorReason(e));
}
onClose();
setIsWiping(false);