Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected config loading behaviour #90

Open
kennethkalmer opened this issue Jan 30, 2015 · 1 comment
Open

Unexpected config loading behaviour #90

kennethkalmer opened this issue Jan 30, 2015 · 1 comment
Labels

Comments

@kennethkalmer
Copy link
Owner

Just helped @ranaldobowker debug an issue where a config file loaded by DaemonKit::Config was missing the correct environment name in the top-level of the YAML file, and subsequently blew up badly.

The offending lines in DaemonKit::Config#initialize tests for the presence of the DAEMON_ENV in the hash, and pulls that up one level.

Although this was probably amazing at the time, I think this magic is no longer good practice... We need to figure out how we can improve this and safeguard users from pulling out their hair...

@marcbowes any ideas?

@marcbowes
Copy link
Collaborator

My recommendation is to not have 2 ways (either by-env or top-level) ways of doing it, plus clear guidance when the user gets it wrong, rather than making them read/understand a stacktrace.

def initialize( config_data ) #:nodoc:
  if config_data.has_key?( DAEMON_ENV )
    self.data = config_data[ DAEMON_ENV ]
  else
    raise ArgumentError, "Invalid config (missing key #{DAEMON_ENV.inspect}); " +
      "please refer to user guide / wiki for further details"
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants