diff options
author | Brinda Santh <bs2796@att.com> | 2020-03-06 13:04:37 -0500 |
---|---|---|
committer | Steve Siani <alphonse.steve.siani.djissitchi@ibm.com> | 2020-04-06 11:59:21 -0400 |
commit | 20dcdbc1384a1173d7e63dd666d530908c845a1e (patch) | |
tree | 411fc65137ff224f1ca8683495f06604f72b9092 /ms/blueprintsprocessor/modules/blueprints | |
parent | 4dccd00d6b1399596ed6f1e0c7f08cdb98cbec4f (diff) |
Refactoring BP Code with ErrorCatalog
Issue-ID: CCSDK-2124
Signed-off-by: Steve Siani <alphonse.steve.siani.djissitchi@ibm.com>
Change-Id: Ief468a56f9e7b3ef86c357965aa7b15f0a4cfa22
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints')
-rw-r--r-- | ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt index acb158d89..310c9b05b 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core +import org.apache.commons.lang.exception.ExceptionUtils import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogException import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogExceptionFluent import org.onap.ccsdk.cds.error.catalog.core.ErrorMessage @@ -56,6 +57,14 @@ open class BluePrintProcessorException : ErrorCatalogException, ErrorCatalogExce return this.updateGrpc(type) } + override fun convertToHttp(): BluePrintProcessorException { + return this.inverseToHttp() + } + + override fun convertToGrpc(): BluePrintProcessorException { + return this.inverseToHttp() + } + override fun payloadMessage(message: String): BluePrintProcessorException { return this.updatePayloadMessage(message) } @@ -82,10 +91,26 @@ fun processorException(message: String): BluePrintProcessorException { return BluePrintProcessorException(message) } +fun processorException(message: String, cause: Throwable): BluePrintProcessorException { + return BluePrintProcessorException(message, cause) +} + +fun processorException(cause: Throwable, message: String, vararg args: Any?): BluePrintProcessorException { + return BluePrintProcessorException(cause, message, args) +} + fun processorException(code: Int, message: String): BluePrintProcessorException { return processorException(message).code(code) } +fun processorException(code: Int, message: String, cause: Throwable): BluePrintProcessorException { + return processorException(message, cause).code(code) +} + +fun processorException(code: Int, cause: Throwable, message: String, vararg args: Any?): BluePrintProcessorException { + return processorException(cause, message, args).code(code) +} + fun httpProcessorException(type: String, message: String): BluePrintProcessorException { return processorException(message).http(type) } @@ -106,17 +131,29 @@ fun grpcProcessorException(type: String, domain: String, message: String): BlueP fun httpProcessorException(type: String, domain: String, message: String, cause: Throwable): BluePrintProcessorException { - val bluePrintProcessorException = processorException(message).http(type) - return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, cause) + val bluePrintProcessorException = processorException(message, cause).http(type) + return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) } fun grpcProcessorException(type: String, domain: String, message: String, cause: Throwable): BluePrintProcessorException { - val bluePrintProcessorException = processorException(message).grpc(type) - return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, cause) + val bluePrintProcessorException = processorException(message, cause).grpc(type) + return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) +} + +fun httpProcessorException(type: String, domain: String, message: String, cause: Throwable, vararg args: Any?): + BluePrintProcessorException { + val bluePrintProcessorException = processorException(cause, message, args).http(type) + return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) +} + +fun grpcProcessorException(type: String, domain: String, message: String, cause: Throwable, vararg args: Any?): + BluePrintProcessorException { + val bluePrintProcessorException = processorException(cause, message, args).grpc(type) + return bluePrintProcessorException.addDomainAndErrorMessage(domain, message, ExceptionUtils.getRootCauseMessage(cause)) } -fun BluePrintProcessorException.updateErrorMessage(domain: String, message: String, cause: Throwable): +fun BluePrintProcessorException.updateErrorMessage(domain: String, message: String, cause: String): BluePrintProcessorException { return this.addDomainAndErrorMessage(domain, message, cause).domain(domain) .addErrorPayloadMessage(message) @@ -132,8 +169,7 @@ fun BluePrintProcessorException.updateErrorMessage(domain: String, message: Stri private fun BluePrintProcessorException.addDomainAndErrorMessage( domain: String, message: String, - cause: Throwable = Throwable() + cause: String = "" ): BluePrintProcessorException { - return this.addSubError(ErrorMessage(domain, message, cause.message - ?: "")).domain(domain) + return this.addSubError(ErrorMessage(domain, message, cause)).domain(domain) } |