adding type and subtype to rate limit error

This commit is contained in:
Simon Martín 2018-03-14 17:27:59 +01:00
parent bbedc5f41b
commit cbfeb0158e
2 changed files with 4 additions and 0 deletions

View File

@ -45,6 +45,8 @@ function rateLimit(userLimitsApi, endpointGroup = null) {
if (isBlocked) { if (isBlocked) {
const rateLimitError = new Error('You are over the limits.'); const rateLimitError = new Error('You are over the limits.');
rateLimitError.http_status = 429; rateLimitError.http_status = 429;
rateLimitError.type = 'limit';
rateLimitError.subtype = 'rate-limit';
return next(rateLimitError); return next(rateLimitError);
} }

View File

@ -133,6 +133,8 @@ function assertRateLimitRequest (status, limit, remaining, reset, retry, done =
assert.ok(err); assert.ok(err);
assert.equal(err.message, 'You are over the limits.'); assert.equal(err.message, 'You are over the limits.');
assert.equal(err.http_status, 429); assert.equal(err.http_status, 429);
assert.equal(err.type, 'limit');
assert.equal(err.subtype, 'rate-limit');
} }
if (done) { if (done) {