Skip to content

Commit

Permalink
Improve error messages in bundle/add if files are missing.
Browse files Browse the repository at this point in the history
Instead of cryptic "error: unknown method :close invoked on nil" errors, let
user know file or path does not exist before failing to copy files.
  • Loading branch information
bakpakin committed Sep 7, 2024
1 parent 384ee4f commit 1fcd47d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/boot/boot.janet
Original file line number Diff line number Diff line change
Expand Up @@ -4057,6 +4057,7 @@
(defn- copyfile
[from to]
(def mode (os/stat from :permissions))
(if-not mode (errorf "file %s does not exist" from))
(def b (buffer/new 0x10000))
(with [ffrom (file/open from :rb)]
(with [fto (file/open to :wb)]
Expand Down Expand Up @@ -4382,12 +4383,15 @@
[manifest src &opt dest chmod-mode]
(default dest src)
(def s (sep))
(case (os/stat src :mode)
(def mode (os/stat src :mode))
(if-not mode (errorf "file %s does not exist" src))
(case mode
:directory
(let [absdest (bundle/add-directory manifest dest chmod-mode)]
(each d (os/dir src) (bundle/add manifest (string src s d) (string dest s d) chmod-mode))
absdest)
:file (bundle/add-file manifest src dest chmod-mode)))
:file (bundle/add-file manifest src dest chmod-mode)
(errorf "bad path %s - file is a %s" src mode)))

(defn bundle/add-bin
`Shorthand for adding scripts during an install. Scripts will be installed to
Expand Down

0 comments on commit 1fcd47d

Please sign in to comment.