Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#wrap method to wrap error #3

Open
greyblake opened this issue May 29, 2013 · 1 comment
Open

#wrap method to wrap error #3

greyblake opened this issue May 29, 2013 · 1 comment

Comments

@greyblake
Copy link

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.

@greyblake
Copy link
Author

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:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant