Open
Description
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.