Exception: ThreeScale::Backend::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/3scale/backend/errors.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.codeObject



21
22
23
# File 'lib/3scale/backend/errors.rb', line 21

def self.code
  underscore(name[/[^:]*$/])
end

.underscore(string) ⇒ Object



25
26
27
28
29
# File 'lib/3scale/backend/errors.rb', line 25

def self.underscore(string)
  string.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
         gsub(/([a-z\d])([A-Z])/,'\1_\2').
         downcase
end

Instance Method Details

#codeObject



17
18
19
# File 'lib/3scale/backend/errors.rb', line 17

def code
  self.class.code
end

#http_codeObject

Note: DON’T change this to http_status; Sinatra will pick it up and break!



13
14
15
# File 'lib/3scale/backend/errors.rb', line 13

def http_code
  403
end

#to_xml(options = {}) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/3scale/backend/errors.rb', line 4

def to_xml(options = {})
  xml = Builder::XmlMarkup.new
  xml.instruct! unless options[:skip_instruct]
  xml.error(message, :code => code)

  xml.target!
end