anchor.diff:                                                     throw(invalid_handoff_encoding)
                                   end;
   
  -        %% zlib encoding is a special legacy mode:
  -        BinObj              ->  do_zlib_decode(BinObj)
  +        _                   ->  lager:error("Request to decode invalid handoff object"),
  +                                throw(invalid_handoff_object)
  +
  +    %% An exception means we have a legacy handoff object:
  +    catch
  +        _:_                 -> do_zlib_decode(BinaryObject)
       end.  
   
   do_zlib_decode(BinaryObject) ->
  
positive.code: %% Decode a binary object. We first try to interpret the data as a "new format" object which indicates
  %% its encoding method, but if that fails we use the legacy zlib and protocol buffer decoding:
  decode_binary_object(BinaryObject) ->
      case binary_to_term(BinaryObject) of
          { Method, BinObj } -> 
                                  case Method of
                                      encode_raw  -> {B, K, Val} = binary_to_term(BinObj),
  
negative.code:         encode_raw  -> EncodedObject = term_to_binary({ Bucket, Key, iolist_to_binary(Value) }),
                         return_encoded_binary_object(Method, EncodedObject);
  
          %% zlib encoding is a special case, we return the legacy format:
          encode_zlib -> PBEncodedObject = riak_core_pb:encode_riakobject_pb(#riakobject_pb{bucket=Bucket, key=Key, val=Value}),
                         zlib:zip(PBEncodedObject)
      end.
  