improve handling of ratchet error

This commit is contained in:
Josh Harvey 2018-01-25 20:15:22 +02:00
parent fc17d2cdf8
commit d7a5734818
4 changed files with 6 additions and 3 deletions

View file

@ -76,6 +76,7 @@ function ensureRatchet (oldField, newField, fieldKey) {
const free = ['sendPending', 'error', 'errorCode', 'customerId']
if (_.isNil(oldField)) return true
if (_.includes(fieldKey, monotonic)) return isMonotonic(oldField, newField, fieldKey)
if (_.includes(fieldKey, free)) {
@ -106,7 +107,7 @@ function diff (oldTx, newTx) {
logger.warn('Value from lamassu-machine would violate ratchet [%s]', fieldKey)
logger.warn('Old tx: %j', oldTx)
logger.warn('New tx: %j', newTx)
throw new Error('Value from lamassu-machine would violate ratchet')
throw new E.RatchetError('Value from lamassu-machine would violate ratchet')
}
updatedTx[fieldKey] = newField