Sha256: 217da45dcd4bd5a65a7a647ef2f6e91934725daa47711b44a0204504d1af72a9

Contents?: true

Size: 1.84 KB

Versions: 17

Compression:

Stored size: 1.84 KB

Contents

module Steep
  module Signature
    module Errors
      class Base
        attr_reader :location

        def loc_to_s
          RBS::Location.to_string location
        end

        def to_s
          StringIO.new.tap do |io|
            puts io
          end.string
        end

        def path
          location.buffer.name
        end
      end

      class DuplicatedDefinitionError < Base
        attr_reader :name

        def initialize(name:, location:)
          @name = name
          @location = location
        end

        def puts(io)
          io.puts "#{loc_to_s}\sDuplicatedDefinitionError: name=#{name}"
        end
      end

      class UnknownTypeNameError < Base
        attr_reader :name

        def initialize(name:, location:)
          @name = name
          @location = location
        end

        def puts(io)
          io.puts "#{loc_to_s}\tUnknownTypeNameError: name=#{name}"
        end
      end

      class InvalidTypeApplicationError < Base
        attr_reader :name
        attr_reader :args
        attr_reader :params

        def initialize(name:, args:, params:, location:)
          @name = name
          @args = args
          @params = params
          @location = location
        end

        def puts(io)
          io.puts "#{loc_to_s}\tInvalidTypeApplicationError: name=#{name}, expected=[#{params.join(", ")}], actual=[#{args.join(", ")}]"
        end
      end

      class InvalidMethodOverloadError < Base
        attr_reader :class_name
        attr_reader :method_name

        def initialize(class_name:, method_name:, location:)
          @class_name = class_name
          @method_name = method_name
          @location = location
        end

        def puts(io)
          io.puts "#{loc_to_s}\tInvalidMethodOverloadError: class_name=#{class_name}, method_name=#{method_name}"
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
steep-0.38.0 lib/steep/signature/errors.rb
steep-0.37.0 lib/steep/signature/errors.rb
steep-0.36.0 lib/steep/signature/errors.rb
steep-0.35.0 lib/steep/signature/errors.rb
steep-0.34.0 lib/steep/signature/errors.rb
steep-0.33.0 lib/steep/signature/errors.rb
steep-0.32.0 lib/steep/signature/errors.rb
steep-0.31.1 lib/steep/signature/errors.rb
steep-0.31.0 lib/steep/signature/errors.rb
steep-0.30.0 lib/steep/signature/errors.rb
steep-0.29.0 lib/steep/signature/errors.rb
steep-0.28.0 lib/steep/signature/errors.rb
steep-0.27.0 lib/steep/signature/errors.rb
steep-0.25.0 lib/steep/signature/errors.rb
steep-0.24.0 lib/steep/signature/errors.rb
steep-0.23.0 lib/steep/signature/errors.rb
steep-0.22.0 lib/steep/signature/errors.rb