gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-sync] branch master updated: better error reporting


From: gnunet
Subject: [taler-sync] branch master updated: better error reporting
Date: Tue, 25 Aug 2020 20:56:00 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository sync.

The following commit(s) were added to refs/heads/master by this push:
     new bbdccc0  better error reporting
bbdccc0 is described below

commit bbdccc04ee87736497ff1845a7b70b3d10876b2f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Aug 25 20:55:59 2020 +0200

    better error reporting
---
 src/sync/sync-httpd_backup.c      | 27 +++++++++++++--------------
 src/sync/sync-httpd_backup_post.c | 33 +++++++++++++++++----------------
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/sync/sync-httpd_backup.c b/src/sync/sync-httpd_backup.c
index 73f7b7c..396960f 100644
--- a/src/sync/sync-httpd_backup.c
+++ b/src/sync/sync-httpd_backup.c
@@ -50,30 +50,29 @@ SH_backup_get (struct MHD_Connection *connection,
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
                                        TALER_EC_INTERNAL_INVARIANT_FAILURE,
-                                       "unexpected return status (backup 
missing)");
+                                       NULL);
   case SYNC_DB_OLD_BACKUP_MISMATCH:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
                                        TALER_EC_INTERNAL_INVARIANT_FAILURE,
-                                       "unexpected return status (backup 
mismatch)");
+                                       NULL);
   case SYNC_DB_PAYMENT_REQUIRED:
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_NOT_FOUND,
                                        TALER_EC_SYNC_ACCOUNT_UNKNOWN,
-                                       "account");
+                                       NULL);
   case SYNC_DB_HARD_ERROR:
-    GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_FETCH_ERROR,
-                                       "hard database failure");
+                                       TALER_EC_SYNC_DB_HARD_FETCH_ERROR,
+                                       NULL);
   case SYNC_DB_SOFT_ERROR:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_FETCH_ERROR,
-                                       "soft database failure");
+                                       TALER_EC_SYNC_DB_SOFT_FETCH_ERROR,
+                                       NULL);
   case SYNC_DB_NO_RESULTS:
     {
       struct MHD_Response *resp;
@@ -192,14 +191,14 @@ SH_return_backup (struct MHD_Connection *connection,
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_FETCH_ERROR,
-                                       "hard database failure");
+                                       TALER_EC_SYNC_DB_HARD_FETCH_ERROR,
+                                       NULL);
   case SYNC_DB_SOFT_ERROR:
     GNUNET_break (0);
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_FETCH_ERROR,
-                                       "soft database failure");
+                                       TALER_EC_SYNC_DB_SOFT_FETCH_ERROR,
+                                       NULL);
   case SYNC_DB_NO_RESULTS:
     GNUNET_break (0);
     /* Note: can theoretically happen due to non-transactional nature if
@@ -208,8 +207,8 @@ SH_return_backup (struct MHD_Connection *connection,
        expensive. Just admit to failure ;-) */
     return TALER_MHD_reply_with_error (connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_SYNC_DB_FETCH_ERROR,
-                                       "unexpected empty result set (try 
again?)");
+                                       
TALER_EC_SYNC_DB_INCONSISTENT_FETCH_ERROR,
+                                       NULL);
   case SYNC_DB_ONE_RESULT:
     /* interesting case below */
     break;
diff --git a/src/sync/sync-httpd_backup_post.c 
b/src/sync/sync-httpd_backup_post.c
index c989bbc..8b5411a 100644
--- a/src/sync/sync-httpd_backup_post.c
+++ b/src/sync/sync-httpd_backup_post.c
@@ -602,7 +602,7 @@ handle_database_error (struct BackupContext *bc,
     return TALER_MHD_reply_with_error (bc->con,
                                        MHD_HTTP_NOT_FOUND,
                                        TALER_EC_SYNC_PREVIOUS_BACKUP_UNKNOWN,
-                                       "Cannot update, no existing backup 
known");
+                                       NULL);
   case SYNC_DB_OLD_BACKUP_MISMATCH:
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Conflict detected, returning existing backup\n");
@@ -637,7 +637,7 @@ handle_database_error (struct BackupContext *bc,
     return TALER_MHD_reply_with_error (bc->con,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
                                        TALER_EC_SYNC_DATABASE_FETCH_ERROR,
-                                       "failed to fetch existing record from 
database");
+                                       NULL);
   case SYNC_DB_NO_RESULTS:
     GNUNET_assert (0);
     return MHD_NO;
@@ -695,20 +695,21 @@ SH_backup_post (struct MHD_Connection *connection,
                     &len)) )
       {
         GNUNET_break_op (0);
-        return TALER_MHD_reply_with_error (connection,
-                                           MHD_HTTP_BAD_REQUEST,
-                                           TALER_EC_SYNC_BAD_CONTENT_LENGTH,
-                                           (NULL == lens)
-                                           ? "Content-length value missing"
-                                           : "Content-length value malformed");
+        return TALER_MHD_reply_with_error (
+          connection,
+          MHD_HTTP_BAD_REQUEST,
+          (NULL == lens)
+          ? TALER_EC_SYNC_MALFORMED_CONTENT_LENGTH
+          : TALER_EC_SYNC_MISSING_CONTENT_LENGTH,
+          lens);
       }
       if (len / 1024 / 1024 >= SH_upload_limit_mb)
       {
         GNUNET_break_op (0);
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_PAYLOAD_TOO_LARGE,
-                                           TALER_EC_SYNC_BAD_CONTENT_LENGTH,
-                                           "Content-length value not 
acceptable");
+                                           
TALER_EC_SYNC_EXCESSIVE_CONTENT_LENGTH,
+                                           NULL);
       }
       bc->upload = GNUNET_malloc_large (len);
       if (NULL == bc->upload)
@@ -718,7 +719,7 @@ SH_backup_post (struct MHD_Connection *connection,
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_PAYLOAD_TOO_LARGE,
                                            
TALER_EC_SYNC_OUT_OF_MEMORY_ON_CONTENT_LENGTH,
-                                           "Server out of memory, try again 
later");
+                                           NULL);
       }
       bc->upload_size = (size_t) len;
     }
@@ -739,7 +740,7 @@ SH_backup_post (struct MHD_Connection *connection,
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_BAD_REQUEST,
                                            TALER_EC_SYNC_BAD_IF_MATCH,
-                                           "If-Match does not include not a 
base32-encoded SHA-512 hash");
+                                           NULL);
       }
     }
     {
@@ -759,7 +760,7 @@ SH_backup_post (struct MHD_Connection *connection,
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_BAD_REQUEST,
                                            TALER_EC_SYNC_BAD_SYNC_SIGNATURE,
-                                           "Sync-Signature does not include a 
base32-encoded EdDSA signature");
+                                           NULL);
       }
     }
     {
@@ -779,7 +780,7 @@ SH_backup_post (struct MHD_Connection *connection,
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_BAD_REQUEST,
                                            TALER_EC_SYNC_BAD_IF_NONE_MATCH,
-                                           "If-none-match does not include not 
a base32-encoded SHA-512 hash");
+                                           NULL);
       }
     }
     /* validate signature */
@@ -801,7 +802,7 @@ SH_backup_post (struct MHD_Connection *connection,
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_FORBIDDEN,
                                            TALER_EC_SYNC_INVALID_SIGNATURE,
-                                           "Account signature does not match 
upload");
+                                           NULL);
       }
     }
     /* get ready to hash (done here as we may go async for payments next) */
@@ -923,7 +924,7 @@ SH_backup_post (struct MHD_Connection *connection,
       return TALER_MHD_reply_with_error (connection,
                                          MHD_HTTP_BAD_REQUEST,
                                          TALER_EC_SYNC_INVALID_UPLOAD,
-                                         "Data uploaded does not match Etag 
promise");
+                                         NULL);
     }
   }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]