Skip to content

Commit

Permalink
Handle error for undefined functions
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhanshuguptagit committed Jul 1, 2024
1 parent 3dc5913 commit dfb0c78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/bean/errors.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
{:error (str "label \"" label-name "\" doesn't exist")
:representation (str "label \"" label-name "\" doesn't exist")})

(defn function-not-found []
{:error "function not found"
:representation "function not found"})

(defn spill-error []
{:error "Spill error"
:representation "Spill error"})
Expand Down
7 changes: 4 additions & 3 deletions src/bean/interpreter.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@

(defn apply-f-args [sheet f args & [asts]]
(let [fn-ast (:scalar f)]
(if (fn? fn-ast)
(apply-system-f sheet fn-ast args asts)
(apply-user-f sheet fn-ast args))))
(cond
(:error f) f
(fn? fn-ast) (apply-system-f sheet fn-ast args asts)
:else (apply-user-f sheet fn-ast args))))

(defn apply-f [sheet f asts]
(let [args (eval-asts sheet asts)]
Expand Down

0 comments on commit dfb0c78

Please sign in to comment.