🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
Forms: add error handling (#12)
Marc Klingena96ed4dd1137
diff --git a/src/features/projects/components/NewProjectButton.tsx b/src/features/projects/components/NewProjectButton.tsxindex da9a7c32df..bae72c9808 100644--- a/src/features/projects/components/NewProjectButton.tsx+++ b/src/features/projects/components/NewProjectButton.tsx@@ -53,6 +53,7 @@ export function NewProjectButton({ size = "default" }: NewProjectButtonProps) {const router = useRouter();const createProjectMutation = api.projects.create.useMutation({onSuccess: () => utils.projects.invalidate(),+ onError: (error) => form.setError("name", { message: error.message }),});function onSubmit(values: z.infer<typeof formSchema>) {diff --git a/src/features/projects/server/projectsRouter.ts b/src/features/projects/server/projectsRouter.tsindex 0ba5e8c3e5..8b073952d3 100644--- a/src/features/projects/server/projectsRouter.ts+++ b/src/features/projects/server/projectsRouter.ts@@ -1,4 +1,5 @@import { createTRPCRouter, protectedProcedure } from "@/src/server/api/trpc";+import { TRPCError } from "@trpc/server";import * as z from "zod";export const projectsRouter = createTRPCRouter({@@ -33,7 +34,10 @@ export const projectsRouter = createTRPCRouter({},});if (existingProject) {- throw new Error("Project with this name already exists");+ throw new TRPCError({+ code: "PRECONDITION_FAILED",+ message: "A project with this name already exists",+ });}const project = await ctx.prisma.project.create({diff --git a/src/features/publicApi/components/CreateApiKeyButton.tsx b/src/features/publicApi/components/CreateApiKeyButton.tsxindex 52b26fb418..f40b0ae875 100644--- a/src/features/publicApi/components/CreateApiKeyButton.tsx+++ b/src/features/publicApi/components/CreateApiKeyButton.tsx@@ -33,6 +33,7 @@ export function CreateApiKeyButton(props: { projectId: string }) {const utils = api.useContext();const mutCreateApiKey = api.apiKeys.create.useMutation({onSuccess: () => utils.apiKeys.invalidate(),+ onError: (error) => form.setError("root", { message: error.message }),});const [open, setOpen] = useState(false);const [generatedKeys, setGeneratedKeys] = useState<{