diff --git a/lib/farmbot/celery_script/utils.ex b/lib/farmbot/celery_script/utils.ex index 6b82cf41..9c989fe5 100644 --- a/lib/farmbot/celery_script/utils.ex +++ b/lib/farmbot/celery_script/utils.ex @@ -8,11 +8,16 @@ defmodule Farmbot.CeleryScript.Utils do def ast_to_vec3(%AST{kind: Tool} = ast) do + repo = Farmbot.Repo.current_repo() tool_id = ast.args.tool_id - case Farmbot.Repo.current_repo().one(from p in DBPoint, where: p.tool_id == ^tool_id) do - %{x: x, y: y, z: z} -> - {:ok, new_vec3(x, y, z)} - nil -> {:error, "Could not find tool by id: #{tool_id}"} + case repo.one(from p in DBPoint, where: p.tool_id == ^tool_id) do + %{x: x, y: y, z: z} -> {:ok, new_vec3(x, y, z)} + nil -> + case repo.one(from t in Farmbot.Repo.Tool, where: t.id == ^tool_id) do + %{name: name} -> + {:error, "#{name} is not currently in a tool slot."} + nil -> {:error, "Could not find tool by id: #{tool_id}"} + end end end