Branch: Tag:

2006-05-29

2006-05-29 12:58:55 by Martin Stjernholm <mast@lysator.liu.se>

Produce a good error message if an attribute value can't be decoded.

Rev: lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1.100

2:      // LDAP client protocol implementation for Pike.   // - // $Id: client.pike,v 1.99 2006/05/11 12:36:25 mast Exp $ + // $Id: client.pike,v 1.100 2006/05/29 12:58:55 mast Exp $   //   // Honza Petrous, hop@unibase.cz   //
229:    } \    } while (0)    + #define IMPROVE_DECODE_ERRS(DECODE, ATTR, VALUE, DECODER_FN) do { \ +  if (mixed err = catch {DECODE;}) { \ +  mapping descr1, descr2; \ +  catch (descr1 = get_attr_type_descr (ATTR)); \ +  catch (descr2 = get_attr_type_descr (ATTR, 1)); \ +  catch { \ +  err[0] = \ +  sprintf ("Error decoding value %O for attribute %O " \ +  "using %O: %s" \ +  "Used attribute type %O, server reports %O\n", \ +  VALUE, ATTR, DECODER_FN, err[0], descr1, descr2); \ +  }; \ +  throw (err); \ +  } \ +  } while (0) +     if (ldap_version < 3) {    // Use the values raw.    if (flags & SEARCH_LOWER_ATTRS)
258:    // send the nowarn flag to get_attr_encoder to avoid    // complaints about that.    get_attr_decoder (attr, DO_IF_DEBUG (dn == ""))) -  attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder); +  IMPROVE_DECODE_ERRS ( +  attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder), +  attr, ASN1_GET_ATTR_VALUES (derattr), decoder);    else    attrs[attr] = ASN1_GET_ATTR_VALUES (derattr);    });
267:    attr = ASN1_GET_ATTR_NAME (derattr);    if (function(string:string) decoder =    get_attr_decoder (attr, DO_IF_DEBUG (dn == ""))) -  attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder); +  IMPROVE_DECODE_ERRS ( +  attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder), +  attr, ASN1_GET_ATTR_VALUES (derattr), decoder);    else    attrs[attr] = ASN1_GET_ATTR_VALUES (derattr);    });
560: Inside #if undefined(PARSE_RFCS)
   void create(string|mapping(string:mixed)|void url, object|void context)    {    -  info = ([ "code_revision" : ("$Revision: 1.99 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.100 $"/" ")[1] ]);       if(!url || !sizeof(url))    url = LDAP_DEFAULT_URL;