add better message for tools not in slots
This commit is contained in:
parent
1662ad94ee
commit
7cbe0aa3c4
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue