class PipeRpc::ErrorResponse; end module PipeRpc class Hub::Message::ErrorResponse < ErrorResponse def initialize(hub, body) @hub = hub super body end def to_error case @code when -32700 then MessageParseError.new(@data.fetch(:message)) when -32600 then InvalidMessageError.new(@data.fetch(:message)) else UnknownError.new(@data[:message]) end end def handle raise to_error end end end