if we create our own exception classes, they need to be subclasses of either class Exception or one of its descendants. : Your Exception « Development « Ruby






if we create our own exception classes, they need to be subclasses of either class Exception or one of its descendants.


class FileSaveError < StandardError
  attr_reader :reason
  def initialize(reason)

    @reason = reason
  end
end

 








Related examples in the same category

1.Ruby exception hierarchy
2.create your own type of exception if you wanted to.