Skip to content

Commit

Permalink
fix: correctly show error messages in toast
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri committed Mar 29, 2024
1 parent 61ebb2a commit ebf8a0f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/components/form/optionSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ const getSupportedCPUGenerations = async () => {
return newRes;
};
</script>../../composables/useCustomFetch
</script>
4 changes: 2 additions & 2 deletions packages/client/src/components/form/uploadedFilesModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function getUploadList() {
});
if (!data?.value?.success || error?.value?.data) {
console.error(data?.value?.error ?? error?.value?.data);
console.error(data?.value?.error ?? error?.value?.data?.error);
toast.error("Error occured. Check console for errors");
return;
Expand All @@ -100,4 +100,4 @@ async function getUploadList() {
.dark tr {
@apply bg-darkgray-800 rounded-lg;
}
</style>../../composables/useCustomFetch
</style>
2 changes: 1 addition & 1 deletion packages/client/src/components/page/appFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ const getPackageVersions = async (): Promise<{ rulesVersion: string } | null> =>
const commit = config.public.COMMIT_HASH,
version = config.public.WEBSITE_VERSION,
packageVersions = await getPackageVersions();
</script>../../composables/useCustomFetch
</script>
4 changes: 2 additions & 2 deletions packages/client/src/pages/results/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ useHead({
const getResult = async (id: string) => {
const { data, error } = await useCustomFetch<{ success: boolean; data?: unknown; error?: string }>(`/result/${id}`);
if (!data?.value?.success || error?.value?.data) {
const message = data.value?.error ?? error.value?.data;
const message = data.value?.error ?? error.value?.data?.error;
console.error(message);
toast.error(message);
router.push("/");
Expand All @@ -126,7 +126,7 @@ const getResult = async (id: string) => {
getSchema = async (ocVersion: string) => {
const { data, error } = await useCustomFetch<{ success: boolean; data?: unknown; error?: string }>(`/schema?v=${ocVersion}`);
if (!data?.value?.success || error?.value?.data) {
const message = data.value?.error ?? error.value?.data;
const message = data.value?.error ?? error.value?.data?.error;
console.error(message);
toast.error(message);
router.push("/");
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/utils/handleForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export const handleForm = async (file: Record<string, unknown>, plistBlob: File)
method: "POST",
body: requestBody,
});
if (!data?.value?.success || error?.value?.data) return { success: false, error: data?.value?.error ?? error?.value?.data ?? "Unknown error" };
if (!data?.value?.success || error?.value?.data)
return { success: false, error: data?.value?.error ?? error?.value?.data?.error ?? "Unknown error" };

setVariable("lastOptions", {
ocVersion,
Expand Down

0 comments on commit ebf8a0f

Please sign in to comment.