Last active
September 3, 2016 17:31
-
-
Save expede/9d3be8b7fa8855c58459f2752fefbc6b to your computer and use it in GitHub Desktop.
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
# 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