module Knj::Errors
This module contains various extra errors used by the other Knj-code.
Public Class Methods
error_str(err, args = {})
click to toggle source
Returns a string describing the given error. Possible arguments can be given if you want the returned string formatted as HTML.
Examples¶ ↑
begin raise 'test' rescue => e print Knj::Errors.error_str(e, :html => true) end
# File lib/knj/errors.rb, line 20 def self.error_str(err, args = {}) if !err.is_a?(Exception) and err.class.name != "Java::JavaLang::LinkageError" raise "Invalid object of class '#{err.class.name}' given." end str = "" if args[:html] str << "<b>#{Knj::Web.html(err.class.name)}</b>: #{Knj::Web.html(err.message)}<br />\n<br />\n" err.backtrace.each do |bt| str << "#{Knj::Web.html(bt)}<br />\n" end str << "<br />\n<br />\n" else str << "#{err.class.name}: #{err.message}\n\n" str << err.backtrace.join("\n") str << "\n\n" end return str end