Skip to content

Instantly share code, notes, and snippets.

@denisdefreyne
Created May 1, 2013 11:08
Show Gist options
  • Save denisdefreyne/5494762 to your computer and use it in GitHub Desktop.
Save denisdefreyne/5494762 to your computer and use it in GitHub Desktop.
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