lib/shelly/cli/backup.rb in shelly-0.1.9 vs lib/shelly/cli/backup.rb in shelly-0.1.10

- old
+ new

@@ -26,13 +26,10 @@ say_new_line print_table(to_display, :ident => 2) else say "No database backups available" end - rescue Client::NotFoundException => e - raise unless e.resource == :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" end desc "get [FILENAME]", "Download database backup" long_desc %{ Download given database backup to current directory. @@ -46,18 +43,13 @@ backup.download(bar.progress_callback) say_new_line say "Backup file saved to #{backup.filename}", :green rescue Client::NotFoundException => e - case e.resource - when :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" - when :database_backup - say_error "Backup not found", :with_exit => false - say "You can list available backups with `shelly backup list` command" - else; raise - end + raise unless e.resource == :database_backup + say_error "Backup not found", :with_exit => false + say "You can list available backups with `shelly backup list` command" end desc "create [DB_KIND]", "Create backup of given database" long_desc %{ Create backup of given database. @@ -68,13 +60,10 @@ app.request_backup(kind) say "Backup requested. It can take up to several minutes for " + "the backup process to finish and the backup to show up in backups list.", :green rescue Client::ValidationException => e say_error e[:message] - rescue Client::NotFoundException => e - raise unless e.resource == :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" end desc "restore FILENAME", "Restore database to state from given backup" def restore(filename) app = multiple_clouds(options[:cloud], "backup restore FILENAME") @@ -84,17 +73,12 @@ ask_to_restore_database app.restore_backup(filename) say_new_line say "Restore has been scheduled. Wait a few minutes till database is restored.", :green rescue Client::NotFoundException => e - case e.resource - when :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" - when :database_backup - say_error "Backup not found", :with_exit => false - say "You can list available backups with `shelly backup list` command" - else; raise - end + raise unless e.resource == :database_backup + say_error "Backup not found", :with_exit => false + say "You can list available backups with `shelly backup list` command" end end end end