Created
September 27, 2016 12:28
-
-
Save psylone/b10a1f0777e8972a6cfc3b5311e66c07 to your computer and use it in GitHub Desktop.
Nice way to create custom exception classes in Ruby
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 SpaceCraft | |
%i[ | |
LowFuelError | |
LowEnergyError | |
].each { |exception| self.const_set(exception, Class.new(StandardError)) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment