added more error messages

Mon, 19 Aug 2013 14:23:00 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 19 Aug 2013 14:23:00 +0200
changeset 22
e593f7e41be0
parent 21
78935b45e2ce
child 23
2b0a7361f15c

added more error messages

dav/main.c file | annotate | diff | comparison | revisions
dav/webdav.c file | annotate | diff | comparison | revisions
dav/webdav.h file | annotate | diff | comparison | revisions
--- a/dav/main.c	Mon Aug 19 12:50:42 2013 +0200
+++ b/dav/main.c	Mon Aug 19 14:23:00 2013 +0200
@@ -595,7 +595,11 @@
         if(sn->error = DAV_NOT_FOUND) {
             res = dav_resource_new(sn, path);
         } else {
-            fprintf(stderr, "error\n");
+            if(sn->errorstr) {
+                fprintf(stderr, "Error: %s\n", sn->errorstr);
+            } else {
+                fprintf(stderr, "Error\n");
+            }
             return -1;
         }
     } else if(res->iscollection) {
@@ -634,6 +638,9 @@
     if(dav_store(res)) {
         print_resource_error(sn, res->path);
         fprintf(stderr, "Cannot upload file.\n");
+        if(sn->errorstr) {
+            fprintf(stderr, "%s\n", sn->errorstr);
+        }
         fclose(in);
         return -1;
     }
--- a/dav/webdav.c	Mon Aug 19 12:50:42 2013 +0200
+++ b/dav/webdav.c	Mon Aug 19 14:23:00 2013 +0200
@@ -113,6 +113,8 @@
         return NULL;
     }
     DavSession *sn = malloc(sizeof(DavSession));
+    sn->errorstr = NULL;
+    sn->error = CURLE_OK;
     if(url.ptr[url.length - 1] == '/') {
         sn->base_url = strdup(base_url);
     } else {
@@ -186,6 +188,11 @@
     } else {
         sn->error = DAV_ERROR;
     }
+    if(c != CURLE_OK) {
+        sn->errorstr = curl_easy_strerror(c);
+    } else {
+        sn->errorstr = NULL;
+    }
 }
 
 void dav_session_destroy(DavSession *sn) { 
--- a/dav/webdav.h	Mon Aug 19 12:50:42 2013 +0200
+++ b/dav/webdav.h	Mon Aug 19 14:23:00 2013 +0200
@@ -94,6 +94,7 @@
     UcxMempool    *mp;
     UcxAllocator  *allocator;
     DavError      error;
+    const char    *errorstr;
 };
 
 struct DavContext {

mercurial