Exception: CmisServer::CmisStandardError
- Inherits:
-
StandardError
- Object
- StandardError
- CmisServer::CmisStandardError
- Defined in:
- lib/cmis_server/exceptions.rb
Direct Known Subclasses
ConstraintViolation, InvalidArgument, InvalidOperation, InvalidType, InvalidTypeDefinition, NotSupported, ObjectNotFound, RuntimeError
Instance Attribute Summary collapse
-
#debug_data ⇒ Object
readonly
Returns the value of attribute debug_data.
-
#http_status_code ⇒ Object
readonly
Returns the value of attribute http_status_code.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
Instance Method Summary collapse
- #http_status ⇒ Object
-
#initialize(attrs = {}) ⇒ CmisStandardError
constructor
A new instance of CmisStandardError.
- #log(logger) ⇒ Object
- #message(debug: CmisServer.configuration.debug) ⇒ Object
- #summary ⇒ Object
- #to_h(debug: CmisServer.configuration.debug) ⇒ Object
- #to_xml(debug: CmisServer.configuration.debug) ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ CmisStandardError
Returns a new instance of CmisStandardError.
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 (readonly)
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 (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/cmis_server/exceptions.rb', line 5 def title @title end |
#trigger ⇒ Object (readonly)
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.})" 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 (debug: CmisServer.configuration.debug) =self.summary += " It was initially triggered by : #{@trigger}" if @trigger&&debug 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 |