Sha256: 05ddeaeccc5a605a4c12842950707cd9ebc0a724165ba021df210246c04c3b05

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require_relative 'base_error'

module Reek
  module Errors
    # Gets raised when Reek is unable to process the source due to an EncodingError
    class EncodingError < BaseError
      TEMPLATE = "Source '%<source>s' cannot be processed by Reek due to an encoding error in the source file.".freeze

      LONG_TEMPLATE = <<-MESSAGE.freeze
        !!!
        %<message>s

        This is a problem that is outside of Reek's scope and should be fixed by you, the
        user, in order for Reek being able to continue.
        Check out this article for an idea on how to get started:
        https://www.justinweiss.com/articles/3-steps-to-fix-encoding-problems-in-ruby/

        Exception message:

        %<exception>s

        Original backtrace:

        %<original>s

        !!!
      MESSAGE

      def initialize(origin:)
        super format(TEMPLATE, source: origin)
      end

      def long_message
        format(LONG_TEMPLATE,
               message: message,
               exception: cause.inspect,
               original: cause.backtrace.join("\n\t"))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reek-4.8.2 lib/reek/errors/encoding_error.rb
reek-4.8.1 lib/reek/errors/encoding_error.rb
reek-4.8.0 lib/reek/errors/encoding_error.rb