From a66e6caedbbe3cd7fa5f8b9ad2525d0a2e1fe76c Mon Sep 17 00:00:00 2001 From: scosman Date: Mon, 7 Oct 2024 10:02:02 -0400 Subject: [PATCH] Nice custom error wrapper for pydanic issues. Adds a "message" field with user readable errors, while keeping the source_errors as well --- .../src/lib/utils/form_container.svelte | 8 +- libs/studio/kiln_studio/custom_errors.py | 24 ++++++ libs/studio/kiln_studio/server.py | 2 + libs/studio/kiln_studio/test_custom_error.py | 74 +++++++++++++++++++ 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 libs/studio/kiln_studio/custom_errors.py create mode 100644 libs/studio/kiln_studio/test_custom_error.py diff --git a/app/web_ui/src/lib/utils/form_container.svelte b/app/web_ui/src/lib/utils/form_container.svelte index be5b6c6..1ab455d 100644 --- a/app/web_ui/src/lib/utils/form_container.svelte +++ b/app/web_ui/src/lib/utils/form_container.svelte @@ -110,9 +110,11 @@ {/if} {#if custom_error_message} -
- {custom_error_message} -
+ {#each custom_error_message.split("\n") as error_line} +
+ {error_line} +
+ {/each} {/if}