airpaulg / relax-net

Automatically exported from code.google.com/p/relax-net
GNU General Public License v3.0
0 stars 0 forks source link

Add error handling to Document.Save() #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The class __DocumentResponse should add fields "error" and "reason" and set 
those in the ToDocument() method. Without them, I see no way of handling errors 
on saving a document.

I could be missing something here and would be happy to hear it.

Original issue reported on code.google.com by anjdreas on 31 Mar 2012 at 4:32

GoogleCodeExporter commented 9 years ago
Example error from CouchDB:

HTTP/1.1 409 Conflict
Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
Content-Length: 33
Connection: close

{"error":"conflict","reason":"Document update conflict."}

Original comment by anjdreas on 31 Mar 2012 at 4:33

GoogleCodeExporter commented 9 years ago
Adding the HTTP error code would also be helpful.

I realize that adding these fields to the class Document is not desirable, so I 
would suggest refactoring Session.Save() to return __DocumentResponse instead 
of Document, and possibly let __DocumentResponse hold a reference to the 
Document in questions.

In my eyes this is a better design. Save() should return information any errors 
occurred during saving, instead of just the document that was saved.

Original comment by anjdreas on 31 Mar 2012 at 4:36