diff options
author | Dan Timoney <dtimoney@att.com> | 2020-04-08 15:13:53 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-08 15:13:53 +0000 |
commit | b3be6e54e99ba120624f9195acd5fb0c39a0f2b4 (patch) | |
tree | 63b32742168c7535a35c65ef5059bf3d7fb4cc49 /ms/blueprintsprocessor/modules/blueprints | |
parent | 1cc6f92fa91b1cc546a8c630602bc48ad7f89e76 (diff) | |
parent | 20dcdbc1384a1173d7e63dd666d530908c845a1e (diff) |
Merge "Refactoring BP Code with ErrorCatalog"
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) } |