Skip to content

Commit

Permalink
Properly display error messages for prompt save and clone mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
cephalization committed Jan 11, 2025
1 parent 0812a9e commit 26858a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions app/src/pages/playground/UpsertPromptFromTemplateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SavePromptForm,
SavePromptSubmitHandler,
} from "@phoenix/pages/playground/SavePromptForm";
import { getErrorMessagesFromRelayMutationError } from "@phoenix/utils/errorUtils";

type UpsertPromptFromTemplateProps = {
instanceId: number;
Expand Down Expand Up @@ -109,10 +110,10 @@ export const UpsertPromptFromTemplateDialog = ({
setDialog(null);
},
onError: (error) => {
// eslint-disable-next-line no-console
console.error(error);
const message = getErrorMessagesFromRelayMutationError(error);
notifyError({
title: "Error creating prompt",
message: message?.[0],
});
setDialog(null);
},
Expand Down Expand Up @@ -161,10 +162,10 @@ export const UpsertPromptFromTemplateDialog = ({
setDialog(null);
},
onError: (error) => {
// eslint-disable-next-line no-console
console.error(error);
const message = getErrorMessagesFromRelayMutationError(error);
notifyError({
title: "Error updating prompt",
message: message?.[0],
});
setDialog(null);
},
Expand Down
4 changes: 3 additions & 1 deletion app/src/pages/prompt/ClonePromptDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "@phoenix/components";
import { useNotifySuccess } from "@phoenix/contexts/NotificationContext";
import { ClonePromptDialogMutation } from "@phoenix/pages/prompt/__generated__/ClonePromptDialogMutation.graphql";
import { getErrorMessagesFromRelayMutationError } from "@phoenix/utils/errorUtils";

export const ClonePromptDialog = ({
promptId,
Expand Down Expand Up @@ -78,8 +79,9 @@ export const ClonePromptDialog = ({
});
},
onError: (error) => {
const message = getErrorMessagesFromRelayMutationError(error);
setError("root", {
message: error.message,
message: message?.[0] ?? "An error occurred",
});
},
});
Expand Down

0 comments on commit 26858a7

Please sign in to comment.