Sha256: 440ddb294f7b3b20234a8007b0ec15fbf6f92f8e446c90fdba1a28e163f37218

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

# typed: strict
# frozen_string_literal: true

module Spoom
  module LSP
    class Error < StandardError
      class AlreadyOpen < Error; end
      class BadHeaders < Error; end

      class Diagnostics < Error
        extend T::Sig

        sig { returns(String) }
        attr_reader :uri

        sig { returns(T::Array[Diagnostic]) }
        attr_reader :diagnostics

        sig { params(json: T::Hash[T.untyped, T.untyped]).returns(Diagnostics) }
        def self.from_json(json)
          Diagnostics.new(
            json['uri'],
            json['diagnostics'].map { |d| Diagnostic.from_json(d) }
          )
        end

        sig { params(uri: String, diagnostics: T::Array[Diagnostic]).void }
        def initialize(uri, diagnostics)
          @uri = uri
          @diagnostics = diagnostics
        end
      end
    end

    class ResponseError < Error
      extend T::Sig

      sig { returns(Integer) }
      attr_reader :code

      sig { returns(String) }
      attr_reader :message

      sig { returns(T::Hash[T.untyped, T.untyped]) }
      attr_reader :data

      sig { params(json: T::Hash[T.untyped, T.untyped]).returns(ResponseError) }
      def self.from_json(json)
        ResponseError.new(
          json['code'],
          json['message'],
          json['data']
        )
      end

      sig { params(code: Integer, message: String, data: T::Hash[T.untyped, T.untyped]).void }
      def initialize(code, message, data)
        @code = code
        @message = message
        @data = data
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spoom-1.1.11 lib/spoom/sorbet/lsp/errors.rb
spoom-1.1.10 lib/spoom/sorbet/lsp/errors.rb
spoom-1.1.9 lib/spoom/sorbet/lsp/errors.rb