Module: Micron::Util::Ex

Included in:
Micron
Defined in:
lib/micron/util/ex.rb

Instance Method Summary collapse

Instance Method Details

#dump_ex(ex, include_backtrace = false) ⇒ String

Utility method for converting Exceptions to Strings

Parameters:

  • ex (Exception)
  • include_backtrace (Boolean) (defaults to: false)

Returns:

  • (String)


12
13
14
15
16
17
18
19
# File 'lib/micron/util/ex.rb', line 12

def dump_ex(ex, include_backtrace=false)
  name = ex.respond_to?(:name) ? ex.name : ex.class.to_s
  s = "<#{name}> #{ex.message}"
  if include_backtrace then
    s += "\n  " + filter_backtrace(ex.backtrace).join("\n  ")
  end
  return s
end