Skip to content

Commit

Permalink
Add a note to the README about humanizing exceptions
Browse files Browse the repository at this point in the history
This has proven very useful in our codebase so thought I'd share.
  • Loading branch information
cap10morgan committed May 10, 2023
1 parent 1a735fe commit 310ff1c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ Explain results can be humanized with `malli.error/humanize`:
; :lonlat [nil ["should be a double"]]}}
```

Or if you already have a malli validation exception (e.g. in a catch form):

```clojure
(require '[malli.error :as me])

(try
(m/validate Address {:not "an address"})
(catch Exception e
(-> e ex-data :data :explain me/humanize)))
```

## Custom error messages

Error messages can be customized with `:error/message` and `:error/fn` properties:
Expand Down

0 comments on commit 310ff1c

Please sign in to comment.