From 2893e6c0a459a91a033d357cd15cc4d14e7acbc1 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Sun, 26 Apr 2015 22:20:08 -0500 Subject: Exit with non-zero status when db:create fails * If the create task fails for a reason other than the database already existing, processing should end. This is indicated by a non-zero exit status. * Since the backtrace is already printed to screen, we forgo printing it again by using an explicit call to `exit`. * :warning: This modifies the behavior of the db:create task slightly in that the stack trace is no longer printed by default. If the `--trace` option is used, it will print the trace _after_ the error message. --- activerecord/lib/active_record/tasks/database_tasks.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/tasks') diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index ea7927a435..f243bf4bfc 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -94,8 +94,9 @@ module ActiveRecord rescue DatabaseAlreadyExists $stderr.puts "#{configuration['database']} already exists" rescue Exception => error - $stderr.puts error, *(error.backtrace) + $stderr.puts error $stderr.puts "Couldn't create database for #{configuration.inspect}" + raise end def create_all -- cgit v1.2.3