-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds error handling for group name length #6
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import ExtendableError from 'es6-error' | ||
|
||
class GroupNameCharLimitExceeded extends ExtendableError { | ||
constructor () { | ||
super('GeniusLink group name is longer than the max character limit of 20 characters') | ||
} | ||
} | ||
|
||
class AddLinkToGroupFailed extends ExtendableError { | ||
constructor () { | ||
super('Genius API could not generate a code, but still came back with 200') | ||
} | ||
} | ||
|
||
export { | ||
GroupNameCharLimitExceeded, | ||
AddLinkToGroupFailed | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
|
||
import initGeniusLink from './initGeniusLink' | ||
import addGroup from './requests/addGroup' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
|
||
import { setApiKeys } from './request' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
|
||
import test from 'ava' | ||
import nock from 'nock' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
|
||
import fetch, { retriers } from 'json-fetch' | ||
import qs from 'query-string' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* @flow */ | ||
|
||
import test from 'ava' | ||
import nock from 'nock' | ||
|
||
import { AddLinkToGroupFailed } from '../errors' | ||
|
||
import addLinkToGroup from './addLinkToGroup' | ||
|
||
test(`create a new tracked link`, async (t) => { | ||
|
@@ -37,5 +37,6 @@ test('If genius replies with 200 but LinkResponses contains an error message, th | |
}] | ||
}) | ||
|
||
await t.throws(addLinkToGroup(LINK, GROUP_ID), 'Genius API could not generate a code, but still came back with 200') | ||
const error = await t.throwsAsync(addLinkToGroup(LINK, GROUP_ID)) | ||
t.truthy(error instanceof AddLinkToGroupFailed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest you use But in this case, I would also suggest passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok thanks! |
||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
|
||
import { makeGetRequest } from '../request' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
|
||
import test from 'ava' | ||
import nock from 'nock' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
import { pathOr } from 'ramda' | ||
|
||
import { makeGetRequest } from '../request' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @flow */ | ||
// @flow | ||
|
||
import test from 'ava' | ||
import nock from 'nock' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass an error class as the second argument to
throwsAsync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure sure