You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2013/07/14 23:12:04 UTC

svn commit: r1503058 - /subversion/trunk/subversion/libsvn_subr/utf.c

Author: danielsh
Date: Sun Jul 14 21:12:04 2013
New Revision: 1503058

URL: http://svn.apache.org/r1503058
Log:
svn_utf_*: Improve error handling.

This follows up to r1503048 (which reverted r1503030,r1503032) by
reimplementing those two revisions in the correct layer.

Suggested by: rhuijben

* subversion/libsvn_subr/utf.c
  (xlate_alloc_handle): Prefix the name of the library generating the error to
    the error message.  Also wrap the generic error code (APR_EINVAL,
    APR_ENOTIMPL, APR_EGENERAL) by a Subversion one (which is not used elsewhere
    in trunk).

Modified:
    subversion/trunk/subversion/libsvn_subr/utf.c

Modified: subversion/trunk/subversion/libsvn_subr/utf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/utf.c?rev=1503058&r1=1503057&r2=1503058&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/utf.c (original)
+++ subversion/trunk/subversion/libsvn_subr/utf.c Sun Jul 14 21:12:04 2013
@@ -212,6 +212,7 @@ xlate_alloc_handle(xlate_handle_node_t *
 {
   apr_status_t apr_err;
   apr_xlate_t *handle;
+  const char *name;
 
   /* The error handling doesn't support the following cases, since we don't
      use them currently.  Catch this here. */
@@ -224,8 +225,10 @@ xlate_alloc_handle(xlate_handle_node_t *
 #if defined(WIN32)
   apr_err = svn_subr__win32_xlate_open((win32_xlate_t **)&handle, topage,
                                        frompage, pool);
+  name = "win32-xlate: ";
 #else
   apr_err = apr_xlate_open(&handle, topage, frompage, pool);
+  name = "APR: ";
 #endif
 
   if (APR_STATUS_IS_EINVAL(apr_err) || APR_STATUS_IS_ENOTIMPL(apr_err))
@@ -253,8 +256,13 @@ xlate_alloc_handle(xlate_handle_node_t *
       /* Just put the error on the stack, since svn_error_create duplicates it
          later.  APR_STRERR will be in the local encoding, not in UTF-8, though.
        */
-      svn_strerror(apr_err, apr_strerr, sizeof(apr_strerr));
-      return svn_error_create(apr_err, 
+#ifdef SVN_DEBUG
+      SVN_ERR_ASSERT(strlen(name) < sizeof(apr_strerr));
+#endif
+      strcpy(apr_strerr, name);
+      svn_strerror(apr_err, apr_strerr + strlen(apr_strerr),
+                   sizeof(apr_strerr) - strlen(apr_strerr));
+      return svn_error_create(SVN_ERR_PLUGIN_LOAD_FAILURE, 
                               svn_error_create(apr_err, NULL, apr_strerr),
                               errstr);
     }