Created
May 8, 2010 13:13
-
-
Save skorfmann/394557 to your computer and use it in GitHub Desktop.
This file contains 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
raise Exception.new | |
#oder | |
raise Exception.new("hallo") | |
#oder auch eigene Exceptions implementieren | |
class MyTinyException < StandardError | |
end | |
raise MyTinyException.new("Super Exception") | |
#oder aber auch mal ein mehr realistisches Beispiel | |
class MyFileNotFoundException < StandardError | |
end | |
class FileParser | |
def self.csv(file_path) | |
raise MyFileNotFoundException.new("File #{file_path}") unless File.exist?(file_path) | |
#parsing logic | |
#... | |
end | |
end | |
begin | |
FileParser.csv("/path/to/not/existing/file") | |
rescue MyFileNotFoundException => e | |
puts e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment