class YolodiceClient::RemoteError
Thrown when an error is received from the server. RemoteError
has two extra attributes: code
and data
that correspond to the values returned in the error object in server response.
Attributes
code[RW]
Error
code, as returned from the server.
data[RW]
Optional data object, if returned by the server.
Public Class Methods
new(error_obj = {'code' => -1, 'message' => "RPC Error"})
click to toggle source
Calls superclass method
# File lib/yolodice_client.rb, line 274 def initialize(error_obj = {'code' => -1, 'message' => "RPC Error"}) @code = error_obj['code'] || -1 @data = error_obj['data'] if error_obj['data'] msg = "#{@code}: #{error_obj['message']}" if @code == 422 && @data && @data.has_key?('errors') msg += ': ' + @data['errors'].to_json end super msg end