You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ma...@apache.org on 2019/05/09 05:28:17 UTC
[incubator-openwhisk] branch master updated: Adjust error handling
in the Cloudant Rest Store (#4325)
This is an automated email from the ASF dual-hosted git repository.
markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 6f4d185 Adjust error handling in the Cloudant Rest Store (#4325)
6f4d185 is described below
commit 6f4d1854813f2cc6e39d16dc7b1e9525f7b5e20e
Author: Martin Henke <ma...@de.ibm.com>
AuthorDate: Thu May 9 07:28:08 2019 +0200
Adjust error handling in the Cloudant Rest Store (#4325)
* correct inconsistent error handling in the couchdb rest store
* remove duplicate metrics by making exceptions distinguishable
---
.../core/database/ArtifactStoreExceptions.scala | 6 ++++++
.../openwhisk/core/database/CouchDbRestStore.scala | 18 +++++++++---------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/common/scala/src/main/scala/org/apache/openwhisk/core/database/ArtifactStoreExceptions.scala b/common/scala/src/main/scala/org/apache/openwhisk/core/database/ArtifactStoreExceptions.scala
index fb6a072..701ff84 100644
--- a/common/scala/src/main/scala/org/apache/openwhisk/core/database/ArtifactStoreExceptions.scala
+++ b/common/scala/src/main/scala/org/apache/openwhisk/core/database/ArtifactStoreExceptions.scala
@@ -27,8 +27,14 @@ case class DocumentTypeMismatchException(message: String) extends ArtifactStoreE
case class DocumentUnreadable(message: String) extends ArtifactStoreException(message)
+case class GetException(message: String) extends ArtifactStoreException(message)
+
case class PutException(message: String) extends ArtifactStoreException(message)
+case class DeleteException(message: String) extends ArtifactStoreException(message)
+
+case class QueryException(message: String) extends ArtifactStoreException(message)
+
sealed abstract class ArtifactStoreRuntimeException(message: String) extends RuntimeException(message)
case class UnsupportedQueryKeys(message: String) extends ArtifactStoreRuntimeException(message)
diff --git a/common/scala/src/main/scala/org/apache/openwhisk/core/database/CouchDbRestStore.scala b/common/scala/src/main/scala/org/apache/openwhisk/core/database/CouchDbRestStore.scala
index 4707781..774cf2e 100644
--- a/common/scala/src/main/scala/org/apache/openwhisk/core/database/CouchDbRestStore.scala
+++ b/common/scala/src/main/scala/org/apache/openwhisk/core/database/CouchDbRestStore.scala
@@ -129,7 +129,7 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
start,
s"[PUT] '$dbName' failed to put document: '${docinfoStr}'; http status: '${code}'",
ErrorLevel)
- throw new Exception("Unexpected http response code: " + code)
+ throw new PutException("Unexpected http response code: " + code)
}
}
@@ -164,7 +164,7 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
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)
+ throw new PutException("Unexpected http response code: " + code)
}
}
@@ -200,7 +200,7 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
start,
s"[DEL] '$dbName' failed to delete document: '${doc}'; http status: '${code}'",
ErrorLevel)
- throw new Exception("Unexpected http response code: " + code)
+ throw new DeleteException("Unexpected http response code: " + code)
}
}
@@ -240,8 +240,8 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
throw NoDocumentException("not found on 'get'")
case Left(code) =>
- transid.finished(this, start, s"[GET] '$dbName' failed to get document: '${doc}'; http status: '${code}'")
- throw new Exception("Unexpected http response code: " + code)
+ transid.failed(this, start, s"[GET] '$dbName' failed to get document: '${doc}'; http status: '${code}'")
+ throw new GetException("Unexpected http response code: " + code)
}
} recoverWith {
case e: DeserializationException => throw DocumentUnreadable(Messages.corruptedEntity)
@@ -310,7 +310,7 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
case Left(code) =>
transid.failed(this, start, s"Unexpected http response code: $code", ErrorLevel)
- throw new Exception("Unexpected http response code: " + code)
+ throw new QueryException("Unexpected http response code: " + code)
}
reportFailure(
@@ -344,7 +344,7 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
case Left(code) =>
transid.failed(this, start, s"Unexpected http response code: $code", ErrorLevel)
- throw new Exception("Unexpected http response code: " + code)
+ throw new QueryException("Unexpected http response code: " + code)
}
reportFailure(
@@ -431,7 +431,7 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
this,
start,
s"[ATT_PUT] '$dbName' failed to upload attachment '$name' of document '$doc'; http status '$code'")
- throw new Exception("Unexpected http response code: " + code)
+ throw new PutException("Unexpected http response code: " + code)
}
}
@@ -495,7 +495,7 @@ class CouchDbRestStore[DocumentAbstraction <: DocumentSerializer](dbProtocol: St
this,
start,
s"[ATT_GET] '$dbName' failed to get attachment '$name' of document '$doc'; http status: '$code'")
- throw new Exception("Unexpected http response code: " + code)
+ throw new GetException("Unexpected http response code: " + code)
}
reportFailure(