Created
May 1, 2013 11:08
-
-
Save denisdefreyne/5494762 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
class InvalidDataException < StandardError | |
attr_accessor :filename | |
end | |
def do_something_with_file(filename) | |
begin | |
self.do_something_with_data(File.read(filename)) | |
rescue InvalidDataException => e | |
e.filename = filename | |
raise e | |
end | |
end | |
def do_something_with_data(data) | |
if !data.start_with?('ABCD') | |
raise InvalidDataException | |
end | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment