2007/7/18, Andreas Schwarz <f / andreas-s.net>: > Hi, > > I have a few methods that check permissions, e.g. > > unless user.can_view?(object) > puts "go away" > end > > What I want do do now is add the possibility to give the caller more > information why the user doesn't have permission. I want to make it > backwards compatible, so returning [false, NotInGroupError(:group => > 'xyz')] is not an option. The only thing I could think of is giving the > function a String or Array that is modified in place: I would not do that - that's plain awful for a language that has multiple return values. Some options I can think of that are better: - create another method returning the reason - use exceptions, i.e. do not check but simply do something and throw if the permission is not granted (typically methods dealing with the file system do it this way) - create another method returning a boolean and a reason, but do not use a question mark as last character in the identifier - invert the logic, i.e. def permission_denied? which returns the reason if forbidden and nil if granted (though I find this a bit hackish) I'd probably favor raising exceptions. Kind regards robert