Skip to content

Instantly share code, notes, and snippets.

@wadie
Created August 3, 2018 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wadie/442724b2eae912c78953ddcdff2da20e to your computer and use it in GitHub Desktop.
Save wadie/442724b2eae912c78953ddcdff2da20e to your computer and use it in GitHub Desktop.
Remove warning
iex(2)> original_stderr = Process.whereis(:standard_error)
#PID<0.59.0>
iex(3)> Process.unregister(:standard_error)
true
iex(4)> {:ok, dev} = StringIO.open("")
{:ok, #PID<0.184.0>}
iex(5)> Process.register(dev, :standard_error)
true
iex(6)> IO.puts :stderr, "Oops!"
:ok
iex(7)> captured = StringIO.flush(dev)
"Oops!\n"
iex(8)> IO.write(original_stderr, captured)
Oops!
:ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment