Improve decoration design-pattern model of exceptions
This commit is contained in:
@@ -3,6 +3,5 @@ package io.smnp.error
|
||||
import io.smnp.environment.Environment
|
||||
|
||||
class EnvironmentException(exception: SmnpException, val environment: Environment) : SmnpException(
|
||||
exception.friendlyName,
|
||||
"${exception.message}\n\nStack trace:\n${environment.stackTrace()}"
|
||||
exception.friendlyName, exception.message, exception
|
||||
)
|
||||
@@ -1,3 +1,12 @@
|
||||
package io.smnp.error
|
||||
|
||||
abstract class SmnpException(val friendlyName: String, message: String? = null) : Exception(message)
|
||||
abstract class SmnpException(val friendlyName: String, message: String? = null, val exception: SmnpException? = null) : Exception(message) {
|
||||
val exceptionChain: List<SmnpException>
|
||||
get() {
|
||||
if(exception == null) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
return listOf(this, *exception.exceptionChain.toTypedArray())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user