Skip to content

Instantly share code, notes, and snippets.

@expede
Last active Sep 3, 2016
Embed
What would you like to do?
# Hypothetical rewrite of `File.read`
# Not the lack of a `OtherFile.read!` (with a bang),
# but we get the same effect with the caller via `>>>`
# Success
iex> OtherFile.read("./existing_file.txt")
"I'm a little teapot short and stout ..."
# Error
# Note that this returns an Exception struct as a value
# and *does not raise*
iex> OtherFile.read("./missing.file")
%OtherFile.NotFoundError{
message: "File not found at ./missing.file",
path: "./missing.file"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment