Module: Knj::Errors

Defined in:
lib/knj/errors.rb

Defined Under Namespace

Classes: Exists, InvalidData, NoAccess, NotFound, Notice, Retry

Class Method Summary collapse

Class Method Details

.error_str(err, args = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/knj/errors.rb', line 9

def self.error_str(err, args = {})
  if !err.is_a?(Exception) and err.class.message != "Java::JavaLang::LinkageError"
    raise "Invalid object of class '#{err.class.name}' given."
  end
  
  str = ""
  
  if args[:html]
    str << "<b>#{err.class.name}</b>: #{err.message}<br />\n<br />\n"
    str << err.backtrace.join("<br />\n")
  else
    str << "#{err.class.name}: #{err.message}\n\n"
    str << err.backtrace.join("\n")
  end
  
  return str
end