schugschug avatar schugschug committed 49661e0

improve error message debugging

Comments (0)

Files changed (5)

ddbmock/database/storage/memory.py

         """
 
         if hash_key not in self.data:
-            raise KeyError('hash_key={} not found'.format(hash_key))
+            raise KeyError('in {} hash_key={} not found {}'.format(self.name,hash_key,self.data.keys()))
         if range_key is None:
             return self.data[hash_key]
         if range_key not in self.data[hash_key]:

ddbmock/database/table.py

         if start and start['HashKeyElement'] != hash_key:
             raise ValidationException("'HashKeyElement' element of 'ExclusiveStartKey' must be the same as the hash_key. Expected {}, got {}".format(hash_key, start['HashKeyElement']))
 
-        data = self.store[hash_value, None]
+
+        try:
+            data = self.store[hash_value, None]
+        except KeyError:
+            data = {}
 
         keys = sorted(data.keys())
 

ddbmock/operations/__init__.py

 
 def load_table(func):
     def loader(post, *args):
+        import inspect
         name = post[u'TableName']
         table = dynamodb.get_table(name)
 
         return func(post, table, *args)
     return loader
-

ddbmock/router/__init__.py

         answer = func(post)
         #req_logger.debug("request_id=%s action=%s answer=%s", post['request_id'], action, answer)
         return answer
-    except (TypeError, ValueError, KeyError) as e:
+    except (TypeError, ValueError, SyntaxError) as e:
+        import traceback
         req_logger.error('C request_id=%s action=%s exception=%s body=%s post=%s', request_id, action, type(e).__name__, str(e.args),post)
+        req_logger.error(traceback.format_exc(limit=7))
+
         raise InternalFailure("{}: {}".format(type(e).__name__, str(e.args)))

ddbmock/utils/stat.py

         self.log.info("%s: interval=%s min=%s max=%s average=%s",
                        self.name,
                        round(interval),
-                       min(points),
-                       max(points),
-                       average(points))
+                       min(points) if points else 'N/A',
+                       max(points) if points else 'N/A',
+                       average(points) if points else 'N/A')
 
         #reset
         self.current_point_list = []
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.