Compare commits

...

1 Commits

Author SHA1 Message Date
Paul Melnikow
3dc4857747 When token pool is empty, surface the error to the badge consumer
Should provide better debuggability in self-hosting cases like #4862 but also on the production server.
2020-04-06 13:16:31 -04:00
2 changed files with 7 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
const crypto = require('crypto')
const PriorityQueue = require('priorityqueuejs')
const { Inaccessible } = require('../base-service/errors')
/**
* Compute a one-way hash of the input string.
@@ -265,7 +266,10 @@ class TokenPool {
}
}
throw Error('Token pool is exhausted')
throw new Inaccessible({
underlyingError: Error('Token pool is exhausted'),
prettyMessage: 'no tokens available',
})
}
/**

View File

@@ -3,12 +3,13 @@
const { expect } = require('chai')
const sinon = require('sinon')
const times = require('lodash.times')
const { Inaccessible } = require('../base-service/errors')
const { Token, TokenPool } = require('./token-pool')
function expectPoolToBeExhausted(pool) {
expect(() => {
pool.next()
}).to.throw(Error, /^Token pool is exhausted$/)
}).to.throw(Inaccessible, /^Inaccessible: Token pool is exhausted$/)
}
describe('The token pool', function() {