mirror of
https://github.com/corda/corda.git
synced 2025-05-09 12:02:56 +00:00
[CORDA-2172]: Add link to error-codes-webapp in Corda. (#4224)
This commit is contained in:
parent
f3b09988a9
commit
aa0ccecfde
@ -22,7 +22,7 @@ class ErrorCodeLoggingTests {
|
|||||||
node.rpc.startFlow(::MyFlow).waitForCompletion()
|
node.rpc.startFlow(::MyFlow).waitForCompletion()
|
||||||
val logFile = node.logFile()
|
val logFile = node.logFile()
|
||||||
|
|
||||||
val linesWithErrorCode = logFile.useLines { lines -> lines.filter { line -> line.contains("[errorCode=") }.toList() }
|
val linesWithErrorCode = logFile.useLines { lines -> lines.filter { line -> line.contains("[errorCode=") }.filter { line -> line.contains("moreInformationAt=https://errors.corda.net/") }.toList() }
|
||||||
|
|
||||||
assertThat(linesWithErrorCode).isNotEmpty
|
assertThat(linesWithErrorCode).isNotEmpty
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,18 @@ import picocli.CommandLine
|
|||||||
*/
|
*/
|
||||||
class CordaVersionProvider : CommandLine.IVersionProvider {
|
class CordaVersionProvider : CommandLine.IVersionProvider {
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val UNKNOWN = "Unknown"
|
||||||
|
const val current_major_release = "4.0-SNAPSHOT"
|
||||||
|
const val platformEditionCode = "OS"
|
||||||
|
|
||||||
private fun manifestValue(name: String): String? = if (Manifests.exists(name)) Manifests.read(name) else null
|
private fun manifestValue(name: String): String? = if (Manifests.exists(name)) Manifests.read(name) else null
|
||||||
|
|
||||||
val releaseVersion: String by lazy { manifestValue("Corda-Release-Version") ?: "Unknown" }
|
val releaseVersion: String by lazy { manifestValue("Corda-Release-Version") ?: UNKNOWN }
|
||||||
val revision: String by lazy { manifestValue("Corda-Revision") ?: "Unknown" }
|
val revision: String by lazy { manifestValue("Corda-Revision") ?: UNKNOWN }
|
||||||
val vendor: String by lazy { manifestValue("Corda-Vendor") ?: "Unknown" }
|
val vendor: String by lazy { manifestValue("Corda-Vendor") ?: UNKNOWN }
|
||||||
val platformVersion: Int by lazy { manifestValue("Corda-Platform-Version")?.toInt() ?: 1 }
|
val platformVersion: Int by lazy { manifestValue("Corda-Platform-Version")?.toInt() ?: 1 }
|
||||||
|
|
||||||
|
internal val semanticVersion: String by lazy { if(releaseVersion == UNKNOWN) current_major_release else releaseVersion }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getVersion(): Array<String> {
|
override fun getVersion(): Array<String> {
|
||||||
|
@ -9,9 +9,9 @@ import org.apache.logging.log4j.core.impl.Log4jLogEvent
|
|||||||
|
|
||||||
@Plugin(name = "ErrorCodeRewritePolicy", category = Core.CATEGORY_NAME, elementType = "rewritePolicy", printObject = false)
|
@Plugin(name = "ErrorCodeRewritePolicy", category = Core.CATEGORY_NAME, elementType = "rewritePolicy", printObject = false)
|
||||||
class ErrorCodeRewritePolicy : RewritePolicy {
|
class ErrorCodeRewritePolicy : RewritePolicy {
|
||||||
override fun rewrite(source: LogEvent?): LogEvent? {
|
override fun rewrite(source: LogEvent): LogEvent? {
|
||||||
val newMessage = source?.message?.withErrorCodeFor(source.thrown, source.level)
|
val newMessage = source.message?.withErrorCodeFor(source.thrown, source.level)
|
||||||
return if (newMessage == source?.message) {
|
return if (newMessage == source.message) {
|
||||||
source
|
source
|
||||||
} else {
|
} else {
|
||||||
Log4jLogEvent.Builder(source).setMessage(newMessage).build()
|
Log4jLogEvent.Builder(source).setMessage(newMessage).build()
|
||||||
|
@ -8,11 +8,13 @@ import java.util.*
|
|||||||
internal fun Message.withErrorCodeFor(error: Throwable?, level: Level): Message {
|
internal fun Message.withErrorCodeFor(error: Throwable?, level: Level): Message {
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
error != null && level.isInRange(Level.FATAL, Level.WARN) -> CompositeMessage("$formattedMessage [errorCode=${error.errorCode()}]", format, parameters, throwable)
|
error != null && level.isInRange(Level.FATAL, Level.WARN) -> CompositeMessage("$formattedMessage [errorCode=${error.errorCode()}, moreInformationAt=${error.errorCodeLocationUrl()}]", format, parameters, throwable)
|
||||||
else -> this
|
else -> this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Throwable.errorCodeLocationUrl() = "https://errors.corda.net/${CordaVersionProvider.platformEditionCode}/${CordaVersionProvider.semanticVersion}/${errorCode()}"
|
||||||
|
|
||||||
private fun Throwable.errorCode(hashedFields: (Throwable) -> Array<out Any?> = Throwable::defaultHashedFields): String {
|
private fun Throwable.errorCode(hashedFields: (Throwable) -> Array<out Any?> = Throwable::defaultHashedFields): String {
|
||||||
|
|
||||||
val hash = staticLocationBasedHash(hashedFields)
|
val hash = staticLocationBasedHash(hashedFields)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user