Commit 74138f0e authored by Vincent Pelletier's avatar Vincent Pelletier

Don't raise generic exceptions in NEO if they can reach user.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2013 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent fb8ae1a6
...@@ -20,6 +20,7 @@ from ZODB.TimeStamp import TimeStamp ...@@ -20,6 +20,7 @@ from ZODB.TimeStamp import TimeStamp
from neo.client.handlers import BaseHandler, AnswerBaseHandler from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.protocol import NodeTypes, ProtocolError from neo.protocol import NodeTypes, ProtocolError
from neo.util import dump from neo.util import dump
from neo.client.exception import NEOStorageError
class StorageEventHandler(BaseHandler): class StorageEventHandler(BaseHandler):
...@@ -61,7 +62,7 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -61,7 +62,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
def answerObject(self, conn, oid, start_serial, end_serial, def answerObject(self, conn, oid, start_serial, end_serial,
compression, checksum, data, data_serial): compression, checksum, data, data_serial):
if data_serial is not None: if data_serial is not None:
raise ValueError, 'Storage should never send non-None ' \ raise NEOStorageError, 'Storage should never send non-None ' \
'data_serial to clients, got %s' % (dump(data_serial), ) 'data_serial to clients, got %s' % (dump(data_serial), )
self.app.local_var.asked_object = (oid, start_serial, end_serial, self.app.local_var.asked_object = (oid, start_serial, end_serial,
compression, checksum, data) compression, checksum, data)
......
...@@ -21,6 +21,7 @@ from neo.tests import NeoTestBase ...@@ -21,6 +21,7 @@ from neo.tests import NeoTestBase
from neo.protocol import NodeTypes from neo.protocol import NodeTypes
from neo.client.handlers.storage import StorageBootstrapHandler, \ from neo.client.handlers.storage import StorageBootstrapHandler, \
StorageAnswersHandler StorageAnswersHandler
from neo.client.exception import NEOStorageError
MARKER = [] MARKER = []
...@@ -83,7 +84,8 @@ class StorageAnswerHandlerTests(NeoTestBase): ...@@ -83,7 +84,8 @@ class StorageAnswerHandlerTests(NeoTestBase):
# Check handler raises on non-None data_serial. # Check handler raises on non-None data_serial.
the_object = (oid, tid1, tid2, 0, '', 'DATA', self.getNextTID()) the_object = (oid, tid1, tid2, 0, '', 'DATA', self.getNextTID())
self.app.local_var.asked_object = None self.app.local_var.asked_object = None
self.assertRaises(ValueError, self.handler.answerObject, conn, *the_object) self.assertRaises(NEOStorageError, self.handler.answerObject, conn,
*the_object)
def test_answerStoreObject(self): def test_answerStoreObject(self):
conn = self.getConnection() conn = self.getConnection()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment