-
-
Save ivancorrales/bf315fa558b00933aae02110b1fa170b to your computer and use it in GitHub Desktop.
Reading a file With Elixir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mix.Tasks.Elixchool.FileProcessor do | |
use Mix.Task | |
def run(filePath) do | |
case File.read(filePath) do | |
{:ok, body} -> process(body) | |
{:error, reason} -> errorHandler(reason) | |
end | |
end | |
defp process(content) do | |
IO.puts content | |
end | |
defp errorHandler (error) do | |
IO.inspect error | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment