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

improve blocks error messages #21615

Merged
merged 3 commits into from
Mar 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export class DocsContext<TRenderer extends Renderer> implements DocsContextProps
referenceMeta(metaExports: ModuleExports, attach: boolean) {
const resolved = this.resolveModuleExport(metaExports);
if (resolved.type !== 'meta')
throw new Error('Cannot reference a non-meta or module export in <Meta of={} />');
throw new Error(
'<Meta of={} /> must reference a CSF file module export or meta export. Did you mistakenly reference your component instead of your CSF file?'
);

if (attach) this.attachCSFFile(resolved.csfFile);
}
Expand Down Expand Up @@ -163,7 +165,10 @@ export class DocsContext<TRenderer extends Renderer> implements DocsContextProps
throw new Error(
`Invalid value passed to the 'of' prop. The value was resolved to a '${prettyType}' type but the only types for this block are: ${validTypes.join(
', '
)}`
)}.
- Did you pass a component to the 'of' prop when the block only supports a story or a meta?
JReinhold marked this conversation as resolved.
Show resolved Hide resolved
- ... or vice versa?
- Did you pass a story, CSF file or meta to the 'of' prop that is not indexed, ie. is not targeted by the 'stories' globs in the main configuration?`
);
}

Expand Down