Sha256: 656254d1dc80bd249edbb1d28509ab720179d99a865832e5c5301c3cf7295a30
Contents?: true
Size: 802 Bytes
Versions: 13
Compression:
Stored size: 802 Bytes
Contents
module PipeRpc class ErrorResponse def initialize(args = {}) @id = args.fetch(:id, nil) error = args.fetch(:error) @code = error.fetch(:code) @message = msg_for(@code) || error.fetch(:message, 'Unknown error') @data = error.fetch(:data, {}) end attr_reader :id, :code, :message, :data def to_h { id: id, error: { code: code, message: message, data: data } } end private def msg_for(code) case code when -32700 then 'Parse error' when -32600 then 'Invalid Request' when -32601 then 'Method not found' when -32602 then 'Invalid arguments' when -32603 then 'Internal error' when -32604 then 'Server not found' when -32605 then 'Reflected error' else nil end end end end
Version data entries
13 entries across 13 versions & 1 rubygems