Class: Embulk::ConfigError

Inherits:
Java::Config::ConfigException
  • Object
show all
Defined in:
lib/embulk/error.rb

Overview

ConfigError is not a ::StandardError but is a java.lang.RuntimeException. “rescue => e” can rescues ConfigError.

Direct Known Subclasses

PluginLoadError

Instance Method Summary collapse

Constructor Details

#initialize(*arguments) ⇒ ConfigError

:call-seq:

ConfigError.new()
ConfigError.new(string)

Returns the new ConfigError object.

The signature of ConfigError.new accepts any argument. But in fact, it accepts only ConfigError.new() and ConfigError.new(String). It raises Error: org.jruby.exceptions.Argument otherwise. It has been like this since Embulk v0.10.38 because a subclass of a Java class is a full Java class as of JRuby 9.3, which introduced some restrictions.

See also:

History

ConfigError.initialize receives only a variable-length argument list (rest parameters) since Embulk v0.10.38. It is to satisfy restrictions as of JRuby 9.3.

It was ConfigError.initialize(message=nil) before v0.10.38. It switched over to call super() (ConfigException()), or super(String) (ConfigException(String)) based on message. It was because Ruby does not allow method overloading, and then, ConfigError can have only a single initialize method.

On the other hand, JRuby 9.3+ does not allow initialize to contain multiple super calls in it. Switching the superclass constructor is no longer accepted in JRuby 9.3+.

To keep compatibility from caller’s viewpoint, ConfigError.initialize receives only a variable-length argument list (*arguments), and calls the superclass constructor with super (without parenthesis). It allows ConfigError.new() and ConfigError.new(String) to call an appropriate superclass constructor for each.

However, ConfigError.new now accepts any argument undesirably. It raises an unexpected Error: org.jruby.exceptions.ArgumentError when ConfigError.new is called with an unexpected argument.



47
48
49
# File 'lib/embulk/error.rb', line 47

def initialize(*arguments)
  super
end