Exception: Rho::RhoError

Inherits:
Exception
  • Object
show all
Defined in:
lib/rho/rhoerror.rb

Constant Summary collapse

ERR_NONE =
0
ERR_NETWORK =
1
ERR_REMOTESERVER =
2
ERR_RUNTIME =
3
ERR_UNEXPECTEDSERVERRESPONSE =
4
ERR_DIFFDOMAINSINSYNCSRC =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(err_code) ⇒ RhoError

Returns a new instance of RhoError.



12
13
14
# File 'lib/rho/rhoerror.rb', line 12

def initialize(err_code)
    @code = err_code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



10
11
12
# File 'lib/rho/rhoerror.rb', line 10

def code
  @code
end

Instance Method Details

#messageObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rho/rhoerror.rb', line 16

def message
    if code == ERR_NETWORK
        return "Could not establish network connection"
    elsif code == ERR_REMOTESERVER
        return "Server returned an error"
    elsif code ==  ERR_RUNTIME
        return "Internal error"
    elsif code ==  ERR_UNEXPECTEDSERVERRESPONSE
        return "Unexpected server response"
    elsif code ==  ERR_DIFFDOMAINSINSYNCSRC
        return "All sync sources should be from one domain"
    end
    
    return "Unknown error"
end