Module: Bridgetown::Errors
- Defined in:
- bridgetown-core/lib/bridgetown-core/errors.rb
Constant Summary collapse
- FatalException =
Class.new(::RuntimeError)
- InvalidConfigurationError =
Class.new(FatalException)
- InvalidDateError =
Class.new(FatalException)
- InvalidYAMLFrontMatterError =
Class.new(FatalException)
- PostURLError =
Class.new(FatalException)
Class Method Summary collapse
-
.print_build_error(exc, trace: false, logger: Bridgetown.logger, server: false) ⇒ Object
rubocop:todo Metrics.
Class Method Details
.print_build_error(exc, trace: false, logger: Bridgetown.logger, server: false) ⇒ Object
rubocop:todo Metrics
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'bridgetown-core/lib/bridgetown-core/errors.rb', line 12 def self.print_build_error(exc, trace: false, logger: Bridgetown.logger, server: false) # rubocop:todo Metrics logger.error "Exception raised:", exc.class.to_s.bold logger.error exc..reset_ansi build_errors_file = Bridgetown.build_errors_path if !server && Bridgetown::Current.site build_errors_data = "#{exc.class}: #{exc.}" trace_args = ["-t", "--trace"] print_trace_msg = true traces = if trace || ARGV.find { |arg| trace_args.include?(arg) } print_trace_msg = false exc.backtrace else exc.backtrace.grep_v(%r!bridgetown-core.+method_missing!)[0..4] end traces.each_with_index do |backtrace_line, index| logger.error "#{index + 1}:", backtrace_line.reset_ansi build_errors_data << "\n#{backtrace_line}" if index < 2 end if build_errors_file FileUtils.mkdir_p(File.dirname(build_errors_file)) File.write(build_errors_file, build_errors_data, mode: "w") end return unless print_trace_msg logger.warn "Backtrace:", "Use the --trace option for complete information." end |