Exception: CmisServer::CmisStandardError
- Inherits:
-
StandardError
- Object
- StandardError
- CmisServer::CmisStandardError
show all
- Defined in:
- lib/cmis_server/exceptions.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
7
8
9
10
11
12
|
# File 'lib/cmis_server/exceptions.rb', line 7
def initialize(attrs= {})
self.http_status_code = attrs.fetch(:http_status, 500)
@debug_data = attrs.fetch(:debug_data, nil)
@trigger = attrs.fetch(:trigger, nil)
@title = attrs.fetch(:title, nil)
end
|
Instance Attribute Details
#debug_data ⇒ Object
Returns the value of attribute debug_data.
5
6
7
|
# File 'lib/cmis_server/exceptions.rb', line 5
def debug_data
@debug_data
end
|
#http_status_code ⇒ Object
Returns the value of attribute http_status_code.
5
6
7
|
# File 'lib/cmis_server/exceptions.rb', line 5
def http_status_code
@http_status_code
end
|
#title ⇒ Object
Returns the value of attribute title.
5
6
7
|
# File 'lib/cmis_server/exceptions.rb', line 5
def title
@title
end
|
#trigger ⇒ Object
Returns the value of attribute trigger.
5
6
7
|
# File 'lib/cmis_server/exceptions.rb', line 5
def trigger
@trigger
end
|
Instance Method Details
#http_status ⇒ Object
14
15
16
|
# File 'lib/cmis_server/exceptions.rb', line 14
def http_status
Rack::Utils::HTTP_STATUS_CODES[self.http_status_code]
end
|
#log(logger) ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/cmis_server/exceptions.rb', line 55
def log(logger)
logger.error "#{self.class.to_s} (#{self.summary})"
logger.info self.backtrace.join("\n") if self.backtrace
if self.trigger
logger.error "Initialy triggered by : #{self.trigger.class.to_s} (#{self.trigger.message})"
logger.info self.trigger.backtrace.join("\n") if self.trigger.backtrace
end
end
|
#message(debug: CmisServer.configuration.debug) ⇒ Object
26
27
28
29
30
|
# File 'lib/cmis_server/exceptions.rb', line 26
def message(debug: CmisServer.configuration.debug)
message=self.summary
message+= " It was initially triggered by : #{@trigger}" if @trigger&&debug
message
end
|
#summary ⇒ Object
22
23
24
|
# File 'lib/cmis_server/exceptions.rb', line 22
def summary
"A #{self.title} error occured."
end
|
#to_h(debug: CmisServer.configuration.debug) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/cmis_server/exceptions.rb', line 32
def to_h(debug: CmisServer.configuration.debug)
h={
title: self.title,
summary: self.summary,
http_status_code: self.http_status_code,
http_status: self.http_status,
}
if debug
h[:debug_data]= self.debug_data.to_h
h[:backtrace] =self.backtrace&.join("\n")
h[:trigger] ={
name: self.trigger,
backtrace: self.trigger&.backtrace&.join("\n")
}
end
h
end
|
#to_xml(debug: CmisServer.configuration.debug) ⇒ Object
50
51
52
53
|
# File 'lib/cmis_server/exceptions.rb', line 50
def to_xml(debug: CmisServer.configuration.debug)
formated_hash=self.to_h(debug: debug).map { |k, v| [k.to_s.camelcase(:lower), v] }.to_h
formated_hash.to_xml(:root => 'error', :skip_instruct => true)
end
|