You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Jason Heeris <ja...@gmail.com> on 2010/10/26 03:51:16 UTC

SVN (numeric) error codes

I'm using PySVN to manipulate a working copy, and I'd like to do
sensible things on error conditions. This involves differentiating
between the errors that could occur — I'd like to do something
different for "File already exists" than, say, "Repository on fire".
As far as I can see, the best way to do this is to use the numeric
error code supplied with the exception[1]. According to the PySVN
docs:

  arg[1] is set to a list of tuples containing the message string and
the error code. The error code values are defined by SVN and APR.

So...

  1. Is there a list of these error codes anywhere? The only thing
I've found is the documentation for a header file[2], which is not
hugely helpful.
  2. Will the error codes remain consistent with future versions of SVN?

[1] http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_clienterror
[2] http://svn.collab.net/svn-doxygen/svn__error__codes_8h.html

Thanks,
Jason

(Please CC me on replies.)

Re: SVN (numeric) error codes

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Jason Heeris wrote on Tue, Oct 26, 2010 at 11:51:16 +0800:
>   1. Is there a list of these error codes anywhere? The only thing
> I've found is the documentation for a header file[2], which is not
> hugely helpful.

That header file is the canonical documentation.  Some functions
document the error codes they return on some possible error condition,
but that's all.  Basically, if you don't find the documentation in any
of the public header files, then you'll have to read the source.

Tangentially, I've been wondering at times whether a macro such as the
following:

	#define svn_error_category(err) \
	        ((err) ? ((err)->apr_err / SVN_ERR_CATEGORY_SIZE) * SVN_ERR_CATEGORY_SIZE : APR_SUCCESS)

	svn_error_t *err = (...);
	apr_status_t category = svn_error_category(err);
	if (err && err->apr_err == SVN_ERR_WC_CATEGORY_START)
		/* local error */;
	else if (err && err->apr_err == SVN_ERR_REPOS_CATEGORY_START)
		/* server-side error */;
	else if (err && err->apr_err == SVN_ERR_FS_CATEGORY_START)
		/* Uh-oh. */;
	else if (err && err->apr_err == SVN_ERR_SVNDIFF_CATEGORY_START)
		/* But I thought YOU made the backups! */;
	else
		...

would be useful.  (I first thought of this while reading 
svn_error_malfunction_handler_t's docstring.)  Opinions?  Use cases?

Also, there is a script, which-error.py, in ^/subversion/trunk/tools,
which converts a numeric error code into a symbolic one.

>   2. Will the error codes remain consistent with future versions of SVN?
> 

Yes, any code that has appeared in a release will be stable across all
1.x versions.

> [1] http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_clienterror
> [2] http://svn.collab.net/svn-doxygen/svn__error__codes_8h.html
> 
> Thanks,
> Jason
> 
> (Please CC me on replies.)