elixir multiple arguments with the pipe operator -


i'm trying load large json file , bind variable, here code failing.....

deps = file.open("../depmap.json")     |> io.read(:all)      |> jsx.decode 

i'm getting

** (functionclauseerror) no function clause matching in :io.request/2 (stdlib) io.erl:556: :io.request({:error, :enoent}, {:get_line, :unicode, ""}) (elixir) lib/io.ex:82: io.do_read_all/2 lib/depchecker.ex:6: (module) (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6 

what missing here? i'm assuming result of file.open gets passed first arguement io.read(:all) point of failure here , i'm not sure how rectify this.

file.open returns either {:ok, pid} or {:error, reason}. second 1 in cases when fails. here you're getting {:error, :enoent} meaning file not exist - you'll need figure out what's wrong path there.

you might want use bang version of file.open in pipeline:

deps = file.open!("../depmap.json") |> io.read(:all)  |> jsx.decode 

this 1 behaves file.open, raises exception instead of returning error value. on success though returns pid representing file, need io.read call.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -