Don't propagate internal notary service errors to the client (#2368)

This commit is contained in:
Andrius Dagys 2018-01-16 09:58:23 +00:00 committed by GitHub
parent 1367cd4adb
commit 55b7035a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -158,7 +158,7 @@ class NotaryFlow {
*/
data class TransactionParts(val id: SecureHash, val inputs: List<StateRef>, val timestamp: TimeWindow?, val notary: Party?)
class NotaryException(val error: NotaryError) : FlowException("Error response from Notary - $error")
class NotaryException(val error: NotaryError) : FlowException("Unable to notarise: $error")
@CordaSerializable
sealed class NotaryError {
@ -166,7 +166,7 @@ sealed class NotaryError {
override fun toString() = "One or more input states for transaction $txId have been used in another transaction"
}
/** Thrown if the time specified in the [TimeWindow] command is outside the allowed tolerance. */
/** Occurs when time specified in the [TimeWindow] command is outside the allowed tolerance. */
object TimeWindowInvalid : NotaryError()
data class TransactionInvalid(val cause: Throwable) : NotaryError() {
@ -174,4 +174,8 @@ sealed class NotaryError {
}
object WrongNotary : NotaryError()
data class General(val cause: String): NotaryError() {
override fun toString() = cause
}
}

View File

@ -78,6 +78,9 @@ abstract class TrustedAuthorityNotaryService : NotaryService() {
log.warn("Notary conflicts for $txId: $conflicts")
throw notaryException(txId, e)
}
} catch (e: Exception) {
log.error("Internal error", e)
throw NotaryException(NotaryError.General("Service unavailable, please try again later"))
}
}