Skip to content

Commit

Permalink
Cleaner error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Oct 7, 2024
1 parent bb743df commit 9041a06
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/studio/kiln_studio/custom_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ async def validation_exception_handler(
for error in exc.errors():
field = error["loc"][-1] # Get the field name
message = error["msg"]

# Custom helpers for common errors
if "String should match pattern '^[A-Za-z0-9 _-]+$'" == message:
message = "must consist of only letters, numbers, spaces, hyphens, and underscores"

error_messages.append(f"{field.capitalize()}: {message}")

return JSONResponse(
Expand Down

0 comments on commit 9041a06

Please sign in to comment.