What are the cons of returning an Exception instance instead of raising it in Python? -


I'm working with Python-couchdb and desktopcouch, I'm doing a db.update The function is wrapped with Coachbab. Function for any person who is not familiar with Python-couchdb is following:

  def update (self, document, ** option): "" "Make a large update or submit the document using an HTTP request. & Gt; Server = server ('http: // localhost: 5984 /') >> = Server.create ('python-test')> db.update for doctor ([... document (type = 'person', name = 'john do'), ... document ( Type = 'person', name = 'Mary Jane'), .. document (type = 'city', name = 'gotham city') ...]: ... print reprint (doctor) #doctest: +ELLIPSIS ( True, '...', '...') (True, '...', '...') (True, '...', '...')> gt; & Gt; Dell server ['Python-test'] The return value method of this' is a tubulated list for each element in the sequence of documents. The form `` (Success, Docide, RURAACC) ``, where `` success '' is bullion, indicates whether the update succeeded or not, `` doctoral`` is the document ID, and `` rev_or_exc `` There is either a new document revision, or an exception example (e.g. `Resource Conflict`) If the update fails, if there is no dictionary in the document list, then this method identifies` `item ()` `method that can be used to convert the object to a dictionary Effectively this means that you can also use this method with `schema.Document` objects. : The Ultimate Document: A sequence of dictionaries or `document` objects, or objects in which` `objects ()` `method is provided that can be used to convert them to a dictionary: Return: one on the resulting documents Repeat: Repeat: `` List` `: Reason: Version 0.2" ""  

As you can see, this function does not increase the exceptions that are raised by the Coachb server. But this is what they wanted to update with the ID of a tuple document.

One of the reviewers went to the #rithon on IRC to ask about the case. Instead of using superficial values, imaging can not be just an approach practical, because there are very few exceptions which can be achieved. My question is, with exceptions Besides using exceptions, what is the use of exceptions worthless?

I think that It is ok to fix the exception in this case, because some parts of the update function can be successful and some may fail. When you increase the exception, the API user has no control which was already successful.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -