From 6f4e8630914b2999b3a8596776d9b35eac9d0929 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 17 Mar 2012 16:41:27 -0700 Subject: [PATCH] Expose errors to users during build rather than burying them in output files. --- middleman-core/lib/middleman-core/cli/build.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index d9a55fa3..ae540ec8 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -35,8 +35,7 @@ module Middleman::Cli # @return [void] def build if !ENV["MM_ROOT"] - $stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?" - exit(1) + raise Thor::Error "Error: Could not find a Middleman project config, perhaps you are in the wrong folder?" end self.class.shared_instance(options["verbose"] || false) @@ -103,11 +102,14 @@ module Middleman::Cli begin response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20")) - create_file(output_file, response.body, { :force => true }) + if response.status == 200 + create_file(output_file, response.body, { :force => true }) + else + raise Thor::Error.new response.body + end rescue say_status :error, output_file, :red - puts $! - abort + raise Thor::Error.new $! end end end