Class: RubynCode::IDE::Handlers::PlanInterviewAnswerHandler
- Inherits:
-
Object
- Object
- RubynCode::IDE::Handlers::PlanInterviewAnswerHandler
- Defined in:
- lib/rubyn_code/ide/handlers/plan_interview_answer_handler.rb
Overview
Handles “plan/interview/answer” — feeds the user’s answer into the active InterviewSession, emits the next question OR the final plan via notifications, and returns an empty ack to the extension.
Constant Summary collapse
- SESSION_NOT_FOUND_CODE =
-32_011
- INVALID_INTERVIEW_CODE =
-32_010
Instance Method Summary collapse
- #call(params) ⇒ Object
-
#initialize(server) ⇒ PlanInterviewAnswerHandler
constructor
A new instance of PlanInterviewAnswerHandler.
Constructor Details
#initialize(server) ⇒ PlanInterviewAnswerHandler
Returns a new instance of PlanInterviewAnswerHandler.
13 14 15 |
# File 'lib/rubyn_code/ide/handlers/plan_interview_answer_handler.rb', line 13 def initialize(server) @server = server end |
Instance Method Details
#call(params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubyn_code/ide/handlers/plan_interview_answer_handler.rb', line 17 def call(params) session_id = params['sessionId'].to_s question_id = params['questionId'].to_s answer = params['answer'].to_s session = @server.lookup_interview_session(session_id) unless session raise Protocol::JsonRpcError.new(SESSION_NOT_FOUND_CODE, "Unknown interview session: #{session_id}") end outcome = session.answer(question_id, answer) emit_outcome(session, outcome) {} rescue Megaplan::InterviewSession::InvalidAnswerError => e raise Protocol::JsonRpcError.new(Protocol::INVALID_PARAMS, e.) rescue Megaplan::InterviewSession::MalformedResponseError, Megaplan::PlanProposer::InvalidProposalError => e warn "[PlanInterviewAnswerHandler] interview failed: #{e.}" @server.notify('plan/interview/error', { 'sessionId' => params['sessionId'], 'message' => e. }) @server.drop_interview_session(params['sessionId'].to_s) raise Protocol::JsonRpcError.new(INVALID_INTERVIEW_CODE, e.) end |