class PipeRpc::Hub::Request::Error

Attributes

error[R]

Public Class Methods

new(error) click to toggle source
# File lib/pipe_rpc/hub_request_error.rb, line 4
def initialize(error)
  @error = error
end

Public Instance Methods

backtrace() click to toggle source
# File lib/pipe_rpc/hub_request_error.rb, line 24
def backtrace
  @error.backtrace.to_a.dup.tap do |backtrace|
    # In ruby, backtraces of argument errors have the location of the
    # method definition and not from where it is called as first location
    # in the backtrace. To normalize argument and no method errors,
    # remove the first location for argument errors.
    backtrace.shift if @error.is_a?(::ArgumentError) and not Object.const_defined?(:MRUBY_VERSION)
  end
end
code() click to toggle source
# File lib/pipe_rpc/hub_request_error.rb, line 10
def code
  case @error
  when NoServerError then -32604
  when method_call_error? && ::NoMethodError then -32601
  when method_call_error? && ::ArgumentError then -32602
  when InternalError then -32605
  else -32603
  end
end
message() click to toggle source
# File lib/pipe_rpc/hub_request_error.rb, line 20
def message
  @error.message
end
method_call_error?() click to toggle source
# File lib/pipe_rpc/hub_request_error.rb, line 34
def method_call_error?
  if Object.const_defined?(:MRUBY_VERSION)
    backtrace.first.nil?
  else
    backtrace.first.split(':').first(2) == [CALL_FILE, CALL_LINENO.to_s]
  end
end