working on db logic
Some checks failed
CI/CD Pipeline / build (push) Failing after 3s

This commit is contained in:
2026-03-12 15:01:33 -06:00
parent 399eb9f93f
commit 4dc4814b2f
21 changed files with 573 additions and 256 deletions

View File

@@ -0,0 +1,32 @@
defmodule ElixirAi.Data do
defmacro __using__(_opts) do
quote do
import ElixirAi.Data
require Logger
end
end
defmacro broadcast_error(opts, do: block) do
topic = Keyword.get(opts, :topic)
build_with_db(block, topic)
end
defp build_with_db(block, topic) do
quote do
try do
unquote(block)
rescue
exception ->
Logger.error("Database error: #{Exception.message(exception)}")
Phoenix.PubSub.broadcast(
ElixirAi.PubSub,
unquote(topic),
{:db_error, Exception.message(exception)}
)
{:error, :db_error}
end
end
end
end