You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/04/03 06:48:02 UTC

[GitHub] jiangpengcheng commented on issue #3512: wrap filed rev of BulkEntityResult using Option

jiangpengcheng commented on issue #3512: wrap filed rev of BulkEntityResult using Option
URL: https://github.com/apache/incubator-openwhisk/pull/3512#issuecomment-378145973
 
 
   @markusthoemmes 
   
   if there is an error field in some documents, these documents will be converted to either `DocumentConflictException` or `PutException`(both inherited from `ArtifactStoreException`), while normal documents will be converted to `DocInfo`:
   
   ```scala
       //line 143-163 on whisk/core/database/CouchDbRestStore.scala 
       val f = client.putDocs(ds).map {
         _ match {
           case Right(response) =>
             transid.finished(this, start, s"'$dbName' completed $count documents")
   
             response.convertTo[Seq[BulkEntityResult]].map { singleResult =>
               singleResult.error
                 .map {
                   case "conflict" => Left(DocumentConflictException("conflict on 'bulk_put'"))
                   case e          => Left(PutException(s"Unexpected $e: ${singleResult.reason.getOrElse("")} on 'bulk_put'"))
                 }
                 .getOrElse {
                   Right(singleResult.toDocInfo)
                 }
             }
   
           case Left(code) =>
             transid.failed(this, start, s"'$dbName' failed to put documents, http status: '${code}'", ErrorLevel)
             throw new Exception("Unexpected http response code: " + code)
         }
       }
   ```
   
   I think this logic is good enough
   
   or do you mean deserialize  the whole `BulkEntityResult` as an error?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services