Skip to content
Snippets Groups Projects
Commit 3dc48577 authored by Paul Melnikow's avatar Paul Melnikow
Browse files

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.
parent 4ee26bfc
No related branches found
No related tags found
No related merge requests found
......@@ -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',
})
}
/**
......
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment