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

add non-raising methods to Client #41

Open
tisba opened this issue Mar 31, 2014 · 1 comment
Open

add non-raising methods to Client #41

tisba opened this issue Mar 31, 2014 · 1 comment
Milestone

Comments

@tisba
Copy link

tisba commented Mar 31, 2014

It would be nice to have non-raising methods on Client, like delete_database or create_database_user. In my project I'm automating this (creating databases and users on the fly) and the management code get's quite noise with all those exception handling. One issue is that there are no specific Exceptions: Both examples raise InfluxDB::Error and you have to match the message in order to figure out what the problem was (I'm happy to provide a PR for that too).

Take this real world code e.g.:

def drop_database(database_name, options={})
  influxdb = influx_client(database_name, options)

  begin
    influxdb.delete_database(database_name)
  rescue InfluxDB::Error => e
    raise e unless e.message == "Database #{database_name} doesn't exist"
    false
  end

  true
end

IMO these methods should only return true (or something else) on success and false otherwise. A bang variant could raise on e.g. "not found" errors. They should raise InfluxDB::AuthenticationError though.

def drop_database(database_name, options={})
  influx_client(database_name, options).delete_database(database_name)
end

If accepted, I'm happy to provide a PR.

@toddboom
Copy link
Contributor

@tisba This seems like a reasonable request. Let me take a look at how this would affect the existing interface and we'll see if we can get something in place soon. Thanks!

@dmke dmke mentioned this issue Jun 7, 2016
@dmke dmke added this to the 1.0 milestone Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants