Don't throw exception if no valid file found; instead log it, and return nil.
This commit is contained in:
parent
a574b527c0
commit
53124ab1a8
2 changed files with 17 additions and 10 deletions
|
|
@ -133,7 +133,7 @@
|
|||
* `default-locale` should be a locale specifier to use if no acceptable locale can be
|
||||
identified.
|
||||
|
||||
Returns a map of message keys to strings."
|
||||
Returns a map of message keys to strings; if no useable file is found, returns nil."
|
||||
{:doc/format :markdown}
|
||||
[^String accept-language-header ^String resource-path ^String default-locale]
|
||||
(let [file-path (first
|
||||
|
|
@ -143,14 +143,18 @@
|
|||
#(find-language-file-name % resource-path)
|
||||
(acceptable-languages accept-language-header))))]
|
||||
(timbre/debug (str "Found i18n file at '" file-path "'"))
|
||||
(read-string
|
||||
(slurp
|
||||
(or
|
||||
file-path
|
||||
(.getAbsolutePath
|
||||
(io/file
|
||||
resource-path
|
||||
(str default-locale ".edn"))))))))
|
||||
(try
|
||||
(read-string
|
||||
(slurp
|
||||
(or
|
||||
file-path
|
||||
(.getAbsolutePath
|
||||
(io/file
|
||||
resource-path
|
||||
(str default-locale ".edn"))))))
|
||||
(catch Exception any
|
||||
(timbre/error (str "Failed to load internationalisation because " (.getMessage any)))
|
||||
nil))))
|
||||
|
||||
|
||||
(def get-messages
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue