Skip to content

Commit

Permalink
Added error message for missing or invalid storyName
Browse files Browse the repository at this point in the history
  • Loading branch information
danielduan authored and ndelangen committed May 24, 2017
1 parent 9ca7bd6 commit af524ca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/react/src/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class ClientApi {

storiesOf(kind, m) {
if (!kind && typeof kind !== 'string') {
throw new Error('Invalid kind provided for stories, should be a string');
throw new Error('Invalid or missing kind provided for stories, should be a string');
}

if (m && m.hot) {
Expand All @@ -49,6 +49,10 @@ export default class ClientApi {
});

api.add = (storyName, getStory) => {
if (typeof storyName !== 'string') {
throw new Error(`Invalid or missing storyName provided for a "${kind}" story.`);
}

if (this._storyStore.hasStory(kind, storyName)) {
throw new Error(`Story of "${kind}" named "${storyName}" already exists`);
}
Expand Down

0 comments on commit af524ca

Please sign in to comment.