Suggest re-running command with --trace on fail (#6551)
Merge pull request 6551
This commit is contained in:
parent
1eff0214d1
commit
7e1afd32a5
|
@ -73,6 +73,30 @@ module Jekyll
|
||||||
"Fail if errors are present in front matter"
|
"Fail if errors are present in front matter"
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
|
# Run ::process method in a given set of Jekyll::Command subclasses and suggest
|
||||||
|
# re-running the associated command with --trace switch to obtain any additional
|
||||||
|
# information or backtrace regarding the encountered Exception.
|
||||||
|
#
|
||||||
|
# cmd - the Jekyll::Command to be handled
|
||||||
|
# options - configuration overrides
|
||||||
|
# klass - an array of Jekyll::Command subclasses associated with the command
|
||||||
|
#
|
||||||
|
# Note that all exceptions are rescued..
|
||||||
|
# rubocop: disable RescueException
|
||||||
|
def process_with_graceful_fail(cmd, options, *klass)
|
||||||
|
klass.each { |k| k.process(options) if k.respond_to?(:process) }
|
||||||
|
rescue Exception => e
|
||||||
|
raise e if cmd.trace
|
||||||
|
|
||||||
|
msg = " Please append `--trace` to the `#{cmd.name}` command "
|
||||||
|
dashes = "-" * msg.length
|
||||||
|
Jekyll.logger.error "", dashes
|
||||||
|
Jekyll.logger.error "Jekyll #{Jekyll::VERSION} ", msg
|
||||||
|
Jekyll.logger.error "", " for any additional information or backtrace. "
|
||||||
|
Jekyll.logger.abort_with "", dashes
|
||||||
|
end
|
||||||
|
# rubocop: enable RescueException
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Jekyll
|
||||||
|
|
||||||
c.action do |_, options|
|
c.action do |_, options|
|
||||||
options["serving"] = false
|
options["serving"] = false
|
||||||
Jekyll::Commands::Build.process(options)
|
process_with_graceful_fail(c, options, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -72,25 +72,17 @@ module Jekyll
|
||||||
opts["serving"] = true
|
opts["serving"] = true
|
||||||
opts["watch"] = true unless opts.key?("watch")
|
opts["watch"] = true unless opts.key?("watch")
|
||||||
|
|
||||||
start(opts)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
def start(opts)
|
|
||||||
# Set the reactor to nil so any old reactor will be GCed.
|
# Set the reactor to nil so any old reactor will be GCed.
|
||||||
# We can't unregister a hook so in testing when Serve.start is
|
# We can't unregister a hook so while running tests we don't want to
|
||||||
# called multiple times we don't want to inadvertently keep using
|
# inadvertently keep using a reactor created by a previous test.
|
||||||
# a reactor created by a previous test when our test might not
|
|
||||||
@reload_reactor = nil
|
@reload_reactor = nil
|
||||||
|
|
||||||
config = configuration_from_options(opts)
|
config = configuration_from_options(opts)
|
||||||
if Jekyll.env == "development"
|
config["url"] = default_url(config) if Jekyll.env == "development"
|
||||||
config["url"] = default_url(config)
|
|
||||||
|
process_with_graceful_fail(cmd, config, Build, Serve)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
[Build, Serve].each { |klass| klass.process(config) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue