0
namespace:db do
desc "Populates Database"
task :populate => :environment do
error = true
if error
puts "Error Code 1: There was an error!"
return false
end
end
rake db:migrate
確實導致預期的結果:
Error Code 1: There was an error!
rake aborted!
unexpected return
但隨後:
/home/james/Documents/fertilizer/fertilizer/lib/tasks/custom.rake:131:in `block (3 levels) in <top (required)>'
/home/james/Documents/fertilizer/fertilizer/lib/tasks/custom.rake:104:in `each'
/home/james/Documents/fertilizer/fertilizer/lib/tasks/custom.rake:104:in `block (2 levels) in <top (required)>'
/home/james/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/home/james/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:fertilize7
(See full trace by running task with --trace)
[email protected]:~/Documents/fertilizer/fertilizer$ rake db:fertilize7
rake aborted!
/home/james/Documents/fertilizer/fertilizer/lib/tasks/custom.rake:549: syntax error, unexpected end-of-input, expecting keyword_end
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:641:in `block in run_tasks_blocks'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:641:in `each'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:641:in `run_tasks_blocks'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:244:in `run_tasks_blocks'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:446:in `load_tasks'
/home/james/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/james/Documents/fertilizer/fertilizer/Rakefile:6:in `<top (required)>'
/home/james/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/home/james/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
[email protected]:~/Documents/fertilizer/fertilizer$
我怎樣才能擺脫所有的錯誤報告,報告意外的回報?它分散了真正的錯誤信息(「錯誤代碼1:出現錯誤!」)。