The better way to do this is a closure checking the error returned by the method.  If err != nil then do the put