[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: error codes in client code

From: Daniel Stenberg <daniel_at_haxx.se>
Date: 2002-01-28 17:48:19 CET

On 28 Jan 2002, Karl Fogel wrote:

> You know, I have to admit I wonder if a client (in particular, our
> command-line client) even needs its own error system similar to the
> Subversion libraries. The motivation is not clear...

The "error system" it would have is just its own set of error codes. It would
still use the same "error-creating" functions the rest is using.

> But the client itself has no callers. Can't it just always return an
> svn_error_t based on the underlying error code (which is either an
> svn-specific code, or an apr code), and use the customizable string to
> describe the error to the user?

The current client code calls error_create() (counting... ) some 25 times at
least. I'd say that indicates that the client might need this.

> And on the rare occasions when it needs to throw an error out of whole
> cloth (i.e., not based on an underlying library or apr error), it can just
> use APR_EGENERAL, or something like that. The string would say everything
> that needs to be said, since this is only for human consumption anyway.
> Why does a client need to return specific error codes at all?

Good question. In general I don't think that the error code is what matters
when the client sets the error. What is gonna matter is the textual part as
that is what the user is gonna read and react upon.

But it might still be good reasons to have error codes. For i18n-reasons for
example. When the future swedish user gets a localized error, the error code
should still be the same among svn users, even if the text message itselft
might be considered unreadable to most of the universe! ;-)

> > 2. The errors currently named SVN_ERR_CL_* in the svn_error_codes.h should
> > (if you agree) be used by errors generated by libsvn_client.
>
> Just checking: do you mean that SVN_ERR_CL_ should be the prefix used by
> libsvn_client, and the command-line client would use some other prefix?

Yes.

> In your client_errors.h below, you currently use SVN_ERR_CL_.

Uh, I can't even keep things apart myself. :-) They would need to be changed
to not be this similar.

> (This file lives in subversion/clients/cmdline/, right?)

Right.

> > This is the first draft of 'client_errors.h'. This would need to get more
> > codes added and some codes should possibly be removed from
> > svn_error_codes.h

[snip]

> > #define SVN_ERROR_START \
> > typedef enum svn_client_errno_t { \
> > SVN_CL__WARNING = SVN_ERR_LAST + 1,

[snip]

> I'm a little confused. Isn't this going to redefine the SVN_ERROR_START
> macro? Some files will have to #include both svn_error_codes.h and
> client_errors.h, will this be a problem?
>
> (Instinct tells me I'm missing something obvious here, but I can't put my
> finger on what.)

I ripped out the same method the svn_error_codes.h file is already using, and
that #undefs the macros in the end of the file too, so netiher of the files
would have a problem with the other's SVN_ERROR_START macro.

-- 
      Daniel Stenberg - http://daniel.haxx.se - +46-705-44 31 77
   ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:00 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.