Class: OpenTox::ErrorReport

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actorObject (readonly)

TODO replace params with URIs (errorCause -> OT.errorCause)



34
35
36
# File 'lib/error.rb', line 34

def actor
  @actor
end

#errorCauseObject (readonly)

TODO replace params with URIs (errorCause -> OT.errorCause)



34
35
36
# File 'lib/error.rb', line 34

def errorCause
  @errorCause
end

#errorDetailsObject (readonly)

TODO replace params with URIs (errorCause -> OT.errorCause)



34
35
36
# File 'lib/error.rb', line 34

def errorDetails
  @errorDetails
end

#errorTypeObject (readonly)

TODO replace params with URIs (errorCause -> OT.errorCause)



34
35
36
# File 'lib/error.rb', line 34

def errorType
  @errorType
end

#http_codeObject (readonly)

TODO replace params with URIs (errorCause -> OT.errorCause)



34
35
36
# File 'lib/error.rb', line 34

def http_code
  @http_code
end

#messageObject (readonly)

TODO replace params with URIs (errorCause -> OT.errorCause)



34
35
36
# File 'lib/error.rb', line 34

def message
  @message
end

Class Method Details

.create(error, actor) ⇒ Object

creates a error report object, from an ruby-exception object

Parameters:

  • error (Exception)
  • actor, (String)

    URI of the call that cause the error



51
52
53
54
55
# File 'lib/error.rb', line 51

def self.create( error, actor )
  rest_params = error.rest_params if error.is_a?(OpenTox::RestCallError) and error.rest_params
  backtrace = error.backtrace.short_backtrace if CONFIG[:backtrace]
  ErrorReport.new( error.http_code, error.class.to_s, error.message, actor, error.errorCause, rest_params, backtrace )
end

.from_rdf(rdf) ⇒ Object



57
58
59
60
# File 'lib/error.rb', line 57

def self.from_rdf(rdf)
   = OpenTox::Parser::Owl.from_rdf( rdf, OT.ErrorReport ).
  ErrorReport.new([OT.statusCode], [OT.errorCode], [OT.message], [OT.actor], [OT.errorCause])
end

Instance Method Details

#rdf_contentObject



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/error.rb', line 70

def rdf_content()
  c = {
    RDF.type => [OT.ErrorReport],
    OT.statusCode => @http_code,
    OT.message => @message,
    OT.actor => @actor,
    OT.errorCode => @errorType,
  }
  c[OT.errorCause] = @errorCause.rdf_content if @errorCause
  c
end

#to_rdfxmlObject



82
83
84
85
86
# File 'lib/error.rb', line 82

def to_rdfxml
  s = Serializer::Owl.new
  s.add_resource(CONFIG[:services]["opentox-task"]+"/tmpId/ErrorReport/tmpId", OT.errorReport, rdf_content)
  s.to_rdfxml
end

#to_yaml_propertiesObject

overwrite sorting to make easier readable



63
64
65
66
67
68
# File 'lib/error.rb', line 63

def to_yaml_properties
   p = super
   p = ( p - ["@backtrace"]) + ["@backtrace"] if @backtrace
   p = ( p - ["@errorCause"]) + ["@errorCause"] if @errorCause
   p
end