nesty
nesty copied to clipboard
#wrap method to wrap error
It would be cool to have #wrap or #chain method to wrap error instead of passing it to new.
Example
class MyError
include Nesty::NestedError
end
begin
boooom!
rescue NoMethodError => original_error
my_error = MyError.custom_method_to_build_error_message(with, number, of, parameters)
my_error.wrap(original_error) # That's where I would like to use it
raise my_error
end
Also I can pass original_error to MyError.custom_method_to_build_error_message as additional parameter but I would prefer avoid doing this to not overload interface with parameters and to make it more reusable.
Thanks.
I know that by default it picks the last error using $! variable, but want to do it in more verbose way not confuse my colleagues:)