Skip to content
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

Cleaner error handling for storiesOf #672

Merged
merged 2 commits into from
Mar 28, 2017
Merged

Conversation

Nickman87
Copy link
Contributor

Our entire storybook was broken because of a simple error, we provided undefined as the first parameter of storiesOf.
This was pretty hard to track down as it only results in issues later on during the runtime where storybook tries to manipulate the names that were given to the stories.

If you want I can write extra tests for this usecase, but I would like to know if this is something you want to work on first.

Our entire storybook was broken because of a simple error, we provided `undefined` as the first parameter of `storiesOf`.
This was pretty hard to track down as it only results in issues later on during the runtime where storybook tries to manipulate the names that were given to the stories.
@@ -24,6 +24,10 @@ export default class ClientApi {
}

storiesOf(kind, m) {
if (!kind) {
throw "Invalid kind provided for stories";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build's failing because of a couple simple linting errors.

This should be throw new Error('Invalid kind provided for stories');

Also, remove the whitespace on line 30.

@@ -24,6 +24,10 @@ export default class ClientApi {
}

storiesOf(kind, m) {
if (!kind) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, it might be nice to have this be !kind && typeof kind !== 'string' to be a bit stricter

@Nickman87
Copy link
Contributor Author

Applied the changes

@Nickman87
Copy link
Contributor Author

Can we get this merged? Just stumbled upon the exact same issue again today causing a search for half an hour :)

@ndelangen ndelangen merged commit 822f666 into storybookjs:master Mar 28, 2017
@ndelangen
Copy link
Member

Thank you!

@shilman shilman added the misc label May 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants