On Mon, 2010-08-09, danie...@apache.org wrote:
>  
> +/** Return TRUE if @a err's chain contains the error code @a apr_err.
> + *
> + * @since New in 1.7.
> + */
> +svn_boolean_t
> +svn_error_has_cause(svn_error_t *err, apr_status_t apr_err);

This looks like it could be a useful API.

I would expect to be able to call such a function on a NULL error
pointer, and the result should be FALSE since "no error" doesn't have
any cause that can be expressed in an apr_status_t.
 
> +svn_boolean_t
> +svn_error_has_cause(svn_error_t *err, apr_status_t apr_err)
> +{
> +  svn_error_t *child;
> +
> +  if (! err && ! apr_err)
> +    /* The API doesn't specify the behaviour when ERR is NULL. */
> +    return TRUE;

What's this block for?  The behaviour I mentioned above would fall out
from just removing this block.  It looks like this is so that you can
write svn_error_has_cause(err, APR_SUCCESS) and get TRUE if ERR is NULL
or contains APR_SUCCESS anywhere in its chain, but is that really
useful?

- Julian


> +  for (child = err; child; child = child->child)
> +    if (child->apr_err == apr_err)
> +      return TRUE;
> +
> +  return FALSE;
> +}



Reply via email to