ENT-2054: Logging improvements (#3397)

This commit is contained in:
Viktor Kolomeyko
2018-06-19 15:29:35 +01:00
committed by GitHub
parent 1004c0f534
commit d4b982b9fb
3 changed files with 10 additions and 2 deletions

View File

@ -15,7 +15,7 @@ class NotaryException(
val error: NotaryError,
/** Id of the transaction to be notarised. Can be _null_ if an error occurred before the id could be resolved. */
val txId: SecureHash? = null
) : FlowException("Unable to notarise transaction${txId ?: " "}: $error")
) : FlowException("Unable to notarise transaction ${txId ?: "<Unknown>"} : $error")
/** Specifies the cause for notarisation request failure. */
@CordaSerializable
@ -27,7 +27,9 @@ sealed class NotaryError {
/** Specifies which states have already been consumed in another transaction. */
val consumedStates: Map<StateRef, StateConsumptionDetails>
) : NotaryError() {
override fun toString() = "One or more input states have been used in another transaction"
override fun toString() = "Conflict notarising transaction $txId. " +
"Input states have been used in another transactions, count: ${consumedStates.size}, " +
"content: ${consumedStates.asSequence().joinToString(limit = 5) { it.key.toString() + "->" + it.value }}"
}
/** Occurs when time specified in the [TimeWindow] command is outside the allowed tolerance. */

View File

@ -10,6 +10,7 @@ import net.corda.testing.core.SerializationEnvironmentRule
import org.junit.Rule
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class NotaryExceptionSerializationTest {
@Rule
@ -27,5 +28,6 @@ class NotaryExceptionSerializationTest {
val instanceOnTheOtherSide = instance.serialize().bytes.deserialize<NotaryException>()
assertEquals(instance.error, instanceOnTheOtherSide.error)
assertTrue(instance.error.toString().contains("->"))
}
}