Class: DTK::RestError

Inherits:
Object
  • Object
show all
Defined in:
lib/errors/rest_error.rb

Direct Known Subclasses

Internal, RestUsageError

Defined Under Namespace

Classes: Internal, NotFound, RestUsageError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(err) ⇒ RestError

Returns a new instance of RestError.



31
32
33
34
# File 'lib/errors/rest_error.rb', line 31

def initialize(err)
  @code = nil
  @message = nil
end

Class Method Details

.create(err) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/errors/rest_error.rb', line 22

def self.create(err)
  if RestUsageError.match?(err)
    RestUsageError.new(err)
  elsif NotFound.match?(err)
    NotFound.new(err)
  else
    Internal.new(err)
  end
end

Instance Method Details

#hash_formObject



35
36
37
# File 'lib/errors/rest_error.rb', line 35

def hash_form()
  {:code => code||:error, :message => message||''}
end