Exception: UU::OS::REST::RemoteException

Inherits:
StandardError
  • Object
show all
Defined in:
uu_os_framework-0.29.16/lib/uu/os/rest/remote_exception.rb

Overview

Ancestor of all exceptions thrown by RemoteClient.

Direct Known Subclasses

ClientException, ServerException

Defined Under Namespace

Classes: Attribute, Message

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (RemoteException) initialize(data)

Creates new instance of RemoteException.

Parameters:

  • data (String, Hash)

    Data used for initialization (exception serialized in JSON, Hash with attributes, or exception message)



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/remote_exception.rb', line 31

def initialize(data)
  if (!data.kind_of?String) && (!data.kind_of?Hash)
    raise ArgumentError.new("Parameter must be String or Hash, but was #{data.class}.")
  end
  begin
    data = JSON.parse(data, :symbolize_names => true) if data.kind_of?String
    @id = data[:id]
    @code = data[:code]
    if data[:errorMessages]
      @messages = []
      data[:errorMessages].each do |msg|
        @messages << Message.new(msg)
      end
    end
    if data[:attributes]
      @attributes = []
      data[:attributes].each do |attr|
        @attributes << Attribute.new(attr)
      end
    end
    @stack_trace = data[:stackTrace]
    message = ''
    @messages.each do |msg|
      message << "\n"
      message << msg.to_s
    end

    super(message)
  rescue
    # Response does not contain exception data serialized in valid JSON
    # (it is probably some infrastructure (e.g. Tomcat) exception)
    super(data.to_s)
  end
end

Instance Attribute Details

- (Array<UU::OS::REST::RemoteException::Attribute>) attributes (readonly)

Additional exception attributes.



22
23
24
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/remote_exception.rb', line 22

def attributes
  @attributes
end

- (Array<UU::OS::REST::RemoteException::Message>) messages (readonly)

Exception messages.



18
19
20
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/remote_exception.rb', line 18

def messages
  @messages
end

- (String) stack_trace (readonly)

Sever-side stack trace.

Returns:

  • (String)


26
27
28
# File 'uu_os_framework-0.29.16/lib/uu/os/rest/remote_exception.rb', line 26

def stack_trace
  @stack_trace
end