Skip to content

Commit

Permalink
simplified resume errors
Browse files Browse the repository at this point in the history
- result.login & consent won't be used anyway
- createError not needed when ctx is involved
  • Loading branch information
panva committed Oct 27, 2017
1 parent 4f33c4e commit 047511d
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions lib/shared/resume.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const assert = require('assert');
const createError = require('http-errors');
const uuid = require('uuid/v4');
const url = require('url');
const _ = require('lodash');
Expand Down Expand Up @@ -32,16 +30,9 @@ module.exports = function getResumeAction(provider) {
ctx.cookies.set(provider.cookieName('resume'), null, clearOpts);

if (result.error) {
assert(!result.login, 'login shouldn\'t be provided with an error result');
assert(!result.consent, 'consent shouldn\'t be provided with an error result');
assert(typeof result.error === 'string', 'error should be a string');

const description = result.error_description
? { error_description: result.error_description }
: undefined;
const err = createError(400, result.error, description);

ctx.throw(err);
ctx.throw(400, result.error, {
error_description: result.error_description,
});
}

if (result.login) {
Expand Down

0 comments on commit 047511d

Please sign in to comment.