Sharad
Sharad

Reputation: 31

:erlang.list_to_atom("roster") error when accessing mnesia table

I am trying get mnesia table info from elixir shell.

I have tried to convert the string to atom.

String.to_atom("roster")

I have tried to pass string as list ["roster"]

command -

:ejabberd_admin.mnesia_table_info("roster")

error

ArgumentError
:erlang.list_to_atom("roster")

Upvotes: 1

Views: 93

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121000

Erlang expects a charlist there, not a binary. Use single quotes:

:ejabberd_admin.mnesia_table_info('roster')

Also: Kernel.to_charlist/1, ~c/2.


Documentation on charlists on official site.


Example:

iex(1)> :erlang.list_to_atom("roster")
** (ArgumentError) argument error
    :erlang.list_to_atom("roster")
iex(1)> :erlang.list_to_atom('roster')
:roster

Upvotes: 5

Related Questions