Add minimal error handling
This commit is contained in:
parent
7beca7e0f6
commit
8f1701dabb
|
@ -1,12 +1,16 @@
|
||||||
(ns ludus.loader
|
(ns ludus.loader
|
||||||
(:require [babashka.fs :as fs]))
|
(:require [babashka.fs :as fs]))
|
||||||
|
|
||||||
(defn cwd [] (fs/cwd))
|
(defn cwd [] (fs/cwd))
|
||||||
|
|
||||||
(defn load-import
|
(defn load-import
|
||||||
([file] (-> file (fs/canonicalize) (fs/file) (slurp)))
|
([file]
|
||||||
([file from]
|
(let [path (-> file (fs/canonicalize) (fs/file))]
|
||||||
(load-import
|
(try (slurp path)
|
||||||
(fs/path
|
(catch java.io.FileNotFoundException _
|
||||||
(fs/parent (fs/canonicalize from))
|
(throw (ex-info (str "File " path " not found") {:path path ::error true}))))))
|
||||||
(fs/path file)))))
|
([file from]
|
||||||
|
(load-import
|
||||||
|
(fs/path
|
||||||
|
(fs/parent (fs/canonicalize from))
|
||||||
|
(fs/path file)))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user