Skip to content

Commit

Permalink
Improve error message for bad coercions
Browse files Browse the repository at this point in the history
  • Loading branch information
hyfen committed Aug 4, 2023
1 parent 7196fda commit e0f26bb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/chronicle/etl/configurable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def apply_options(options)
# Do nothing with a given option if it's not a connector setting
next unless setting

@config[name] = coerced_value(setting, value)
@config[name] = coerced_value(setting, name, value)
end
validate_config
options
Expand All @@ -84,12 +84,11 @@ def validate_config
raise Chronicle::ETL::ConnectorConfigurationError, "Missing options: #{missing}" if missing.count.positive?
end

def coerced_value(setting, value)
def coerced_value(setting, name, value)
setting.type ? __send__("coerce_#{setting.type}", value) : value
rescue StandardError
raise(Chronicle::ETL::ConnectorConfigurationError, "Could not coerce #{value} into a #{setting.type}")
raise(Chronicle::ETL::ConnectorConfigurationError, "Could not convert value '#{value}' into a #{setting.type} for setting '#{name}'")
end

def coerce_string(value)
value.to_s
end
Expand Down

0 comments on commit e0f26bb

Please sign in to comment.