mirror of
https://github.com/corda/corda.git
synced 2024-12-20 05:28:21 +00:00
[CORDA-2486] Improve transaction deserialisation errors and fix possible migration issue (#4761)
* Improve error when transaction deserialisation fails and move migrations for finance to contracts CorDapp * Revert move of migrations and errors thrown from CordaRPCOps * Ensure VaultQueryException is thrown from vault queries and remove unused import * Improve error reporting from VaultQueryException * Fix API break * Fix vault query test failure due to exception change
This commit is contained in:
parent
3d362e066c
commit
9b2725d3aa
@ -79,11 +79,17 @@ fun <T : Any> deserialiseComponentGroup(componentGroups: List<ComponentGroup>,
|
|||||||
} catch (e: MissingAttachmentsException) {
|
} catch (e: MissingAttachmentsException) {
|
||||||
throw e
|
throw e
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
throw Exception("Malformed transaction, $groupEnum at index $internalIndex cannot be deserialised", e)
|
throw TransactionDeserialisationException(groupEnum, internalIndex, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception raised if an error was encountered while attempting to deserialise a component group in a transaction.
|
||||||
|
*/
|
||||||
|
class TransactionDeserialisationException(groupEnum: ComponentGroupEnum, index: Int, cause: Exception):
|
||||||
|
Exception("Failed to deserialise group $groupEnum at index $index in transaction: ${cause.message}", cause)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to deserialise Commands from its two groups:
|
* Method to deserialise Commands from its two groups:
|
||||||
* * COMMANDS_GROUP which contains the CommandData part
|
* * COMMANDS_GROUP which contains the CommandData part
|
||||||
|
@ -518,7 +518,9 @@ inline fun <reified T : ContractState> VaultService.trackBy(criteria: QueryCrite
|
|||||||
return _trackBy(criteria, paging, sorting, T::class.java)
|
return _trackBy(criteria, paging, sorting, T::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
class VaultQueryException(description: String) : FlowException(description)
|
class VaultQueryException(description: String, cause: Exception? = null) : FlowException(description, cause) {
|
||||||
|
constructor(description: String) : this(description, null)
|
||||||
|
}
|
||||||
|
|
||||||
class StatesNotAvailableException(override val message: String?, override val cause: Throwable? = null) : FlowException(message, cause) {
|
class StatesNotAvailableException(override val message: String?, override val cause: Throwable? = null) : FlowException(message, cause) {
|
||||||
override fun toString() = "Soft locking error: $message"
|
override fun toString() = "Soft locking error: $message"
|
||||||
|
@ -511,7 +511,13 @@ class NodeVaultService(
|
|||||||
|
|
||||||
@Throws(VaultQueryException::class)
|
@Throws(VaultQueryException::class)
|
||||||
override fun <T : ContractState> _queryBy(criteria: QueryCriteria, paging: PageSpecification, sorting: Sort, contractStateType: Class<out T>): Vault.Page<T> {
|
override fun <T : ContractState> _queryBy(criteria: QueryCriteria, paging: PageSpecification, sorting: Sort, contractStateType: Class<out T>): Vault.Page<T> {
|
||||||
return _queryBy(criteria, paging, sorting, contractStateType, false)
|
try {
|
||||||
|
return _queryBy(criteria, paging, sorting, contractStateType, false)
|
||||||
|
} catch (e: VaultQueryException) {
|
||||||
|
throw e
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw VaultQueryException("An error occurred while attempting to query the vault: ${e.message}", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(VaultQueryException::class)
|
@Throws(VaultQueryException::class)
|
||||||
|
@ -825,7 +825,7 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
|||||||
assertThat(resultsUnlockedAndByLockIds.states).hasSize(5)
|
assertThat(resultsUnlockedAndByLockIds.states).hasSize(5)
|
||||||
|
|
||||||
// missing lockId
|
// missing lockId
|
||||||
expectedEx.expect(IllegalArgumentException::class.java)
|
expectedEx.expect(VaultQueryException::class.java)
|
||||||
expectedEx.expectMessage("Must specify one or more lockIds")
|
expectedEx.expectMessage("Must specify one or more lockIds")
|
||||||
val criteriaMissingLockId = VaultQueryCriteria(softLockingCondition = SoftLockingCondition(SoftLockingType.UNLOCKED_AND_SPECIFIED))
|
val criteriaMissingLockId = VaultQueryCriteria(softLockingCondition = SoftLockingCondition(SoftLockingType.UNLOCKED_AND_SPECIFIED))
|
||||||
vaultService.queryBy<ContractState>(criteriaMissingLockId)
|
vaultService.queryBy<ContractState>(criteriaMissingLockId)
|
||||||
|
Loading…
Reference in New Issue
Block a user