Class: PipeRpc::Hub::Request::Error
- Defined in:
- lib/pipe_rpc/hub_request_error.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #backtrace ⇒ Object
- #code ⇒ Object
-
#initialize(error) ⇒ Error
constructor
A new instance of Error.
- #message ⇒ Object
- #method_call_error? ⇒ Boolean
Constructor Details
#initialize(error) ⇒ Error
Returns a new instance of Error.
4 5 6 |
# File 'lib/pipe_rpc/hub_request_error.rb', line 4 def initialize(error) @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/pipe_rpc/hub_request_error.rb', line 8 def error @error end |
Instance Method Details
#backtrace ⇒ Object
24 25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
10 11 12 13 14 15 16 17 18 |
# 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 ⇒ Object
20 21 22 |
# File 'lib/pipe_rpc/hub_request_error.rb', line 20 def @error. end |
#method_call_error? ⇒ Boolean
34 35 36 37 38 39 40 |
# 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 |