When we define an error class in a module, we do one of the following.
module App class Error < StandardError; end class ServerError < Error; end class ClientError < Error; end end
module App Error = Class.new(StandardError) ServerError = Class.new(Error) ClientError = Class.new(Error) end
IMO, the ugliness of the syntax is partly responsible that not many libraries have custom errors of their own, even when it makes sense.
It would be great if we could write this way instead:
module App define_error Error # inherits StandardError by default define_error ServerError, ClientError < Error # inherits App::Error end
Which would encourage define errors.
I realized that the same could apply to empty class inheritance in general, but errors are much more likely to inherit without adding any features - thus naming specifically