You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3d0c410
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: usage-rules.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ Rules for LLM coding agents using `Localize` as a dependency. These are not exha
4
4
5
5
## Core conventions
6
6
7
-
* All public formatting and validation functions return `{:ok, result}` or `{:error, exception}`. Pattern match with `case`/`with`, never `try/rescue`. The exception is a struct (e.g. `%Localize.UnknownLocaleError{}`), not a string.
7
+
* All public functions that take a *message, locale, number, unit or other user value* return `{:ok, result}` or `{:error, exception}`. Pattern match with `case`/`with`, never `try/rescue`. The exception is a struct (e.g. `%Localize.UnknownLocaleError{}`), not a string.
8
+
9
+
* The exception is the handful of functions that operate on an already-parsed AST rather than on source: they have no message to attach to an exception, so they report a plain reason instead. `Localize.Message.Validator.validate/1` returns `:ok` or `{:error, {reason, detail}}`, and `Localize.Message.JSON.from_json/1` returns `{:error, binary}`. The message-level entry points convert these into a `%Localize.FormatError{}` carrying the source — so `Localize.Message.format/3` and `canonical_message/2` still follow the rule above.
8
10
9
11
* Bang variants (`to_string!/2`, `validate_locale!/1`, etc.) exist for the rare cases where raising is preferred on error.
0 commit comments