diff options
| author | 2024-09-07 09:18:08 -0500 | |
|---|---|---|
| committer | 2024-09-07 09:19:15 -0500 | |
| commit | 1fcd47dd7be416af5ca64cc47e7f01754b90e6f5 (patch) | |
| tree | 0f06a26748dcfd6252ac2a5ec7b819921067fb5e | |
| parent | Merge pull request #1498 from sogaiu/remove-janet-def (diff) | |
Improve error messages in bundle/add if files are missing.
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.
| -rw-r--r-- | src/boot/boot.janet | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/boot/boot.janet b/src/boot/boot.janet index f5f29975..08ac5a08 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -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)] @@ -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 |
