Skip to content

Commit 61de0be

Browse files
committed
Print command errors
1 parent b4b57a6 commit 61de0be

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/alas.janet

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@
4747
plan (parse-result :plan)]
4848
(if parse-errors
4949
(errors/print-errors parse-errors (errors/exit-status-codes :parse-error))
50-
(let [serialize-empty-inbox (plan_parser/serialize-empty-inbox? plan-string)
51-
new-plan (run-commands plan file-path arguments)
52-
new-plan-string (plan_serializer/serialize
50+
(let [{:plan new-plan :errors run-errors} (run-commands plan file-path arguments)]
51+
(if (empty? run-errors)
52+
(let [serialize-empty-inbox (plan_parser/serialize-empty-inbox? plan-string)
53+
new-plan-string (plan_serializer/serialize
5354
new-plan
5455
{:serialize-empty-inbox serialize-empty-inbox})]
55-
(file_repository/save new-plan-string file-path))))))
56+
(file_repository/save new-plan-string file-path))
57+
(errors/print-errors run-errors (errors/exit-status-codes :command-error))))))))
5658

5759
(defn- run-with-arguments [arguments]
5860
(def file-path (arguments :default))

src/errors.janet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
{:error 1
99
:plan-path-missing 2
1010
:file-error 3
11-
:parse-error 4})
11+
:parse-error 4
12+
:command-error 5})
1213

1314
(defn format-command-errors [command errors]
1415
(map (fn [error] (string command " " (string/ascii-lower error) ".")) errors))

0 commit comments

Comments
 (0)