Exception: Mpp::Extensions::MCP::PaymentRequiredError

Inherits:
StandardError
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mpp/extensions/mcp/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(challenges:, message: "Payment Required") ⇒ PaymentRequiredError

Returns a new instance of PaymentRequiredError.



17
18
19
20
21
# File 'lib/mpp/extensions/mcp/errors.rb', line 17

def initialize(challenges:, message: "Payment Required")
  @challenges = T.let(challenges, T.untyped)
  @code = T.let(CODE_PAYMENT_REQUIRED, Integer)
  super(message)
end

Instance Attribute Details

#challengesObject (readonly)

Returns the value of attribute challenges.



11
12
13
# File 'lib/mpp/extensions/mcp/errors.rb', line 11

def challenges
  @challenges
end

#codeObject (readonly)

Returns the value of attribute code.



14
15
16
# File 'lib/mpp/extensions/mcp/errors.rb', line 14

def code
  @code
end

Instance Method Details

#to_jsonrpc_errorObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/mpp/extensions/mcp/errors.rb', line 24

def to_jsonrpc_error
  {
    "code" => CODE_PAYMENT_REQUIRED,
    "message" => message,
    "data" => {
      "httpStatus" => HTTP_STATUS_PAYMENT_REQUIRED,
      "challenges" => @challenges.map(&:to_dict)
    }
  }
end