module FPM::Fry

Public Class Methods

WithData(ex, data) click to toggle source

Annotates an arbitrary exception with logable data.

@example

raise FPM::Fry::WithData("Something went wrong", key: "value")

@param [String,Exception] ex @param [Hash] data @return [Exception] annotated exception

# File lib/fpm/fry/with_data.rb, line 11
def self.WithData(ex, data)
  if ex.kind_of? String
    ex = StandardError.new(ex)
  end
  ex.define_singleton_method(:data){ data }
  return ex
end