grych / drab

Remote controlled frontend framework for Phoenix.

Home Page:https://tg.pl/drab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unclear error message when template is not named .drab

favetelinguis opened this issue · comments

This is the error im getting when the I have not added .drab extension for template. It is not clear that is the issue.

[error] Drab Handler failed with the following exception:
** (Protocol.UndefinedError) protocol Enumerable not implemented for nil. This protocol is implemented for: DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, File.Stream, Floki.HTMLTree, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet,Postgrex.Stream, Range, Stream
    (elixir) /private/tmp/elixir-20180620-82402-14wughj/elixir-1.6.6/lib/elixir/lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir) /private/tmp/elixir-20180620-82402-14wughj/elixir-1.6.6/lib/elixir/lib/enum.ex:141: Enumerable.reduce/3
    (elixir) lib/enum.ex:1919: Enum.reduce/3
    (drab) lib/drab/live.ex:968: Drab.Live.decrypted_assigns/1
    (drab) lib/drab/live.ex:958: Drab.Live.decrypted_from_browser/1
    (drab) lib/drab/live.ex:918: Drab.Live.assigns_and_nodrab/1
    (drab) lib/drab/live.ex:574: Drab.Live.do_poke/5
    (streamdemo) lib/streamdemo_web/commanders/gen_commander.ex:18: StreamdemoWeb.GenCommander.handle_event/1
    (drab) lib/drab.ex:286: anonymous fn/3 in Drab.handle_callback/3

This is the code that throws the exception.

defmodule StreamdemoWeb.GenCommander do
  use Drab.Commander
  require Hub
  require Logger
  onconnect :connected

  def connected(socket) do
    sub = Hub.subscribe("channel", _)
    Logger.debug("Connected and subscribed #{inspect sub}")
    handle_event(socket)
  end

  defp handle_event(socket) do
    receive do
      %{age: age, name: name} = msg  ->
      socket
      |> IO.inspect()
      |> poke(genevent: "dd")
    end
    handle_event(socket)
  end
end

Fix will show up in 0.9.2