Skip to content

added more information to an error message #63

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

Closed
Closed
Changes from all commits
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
23 changes: 22 additions & 1 deletion src/getClassName.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,30 @@ const getClassNameForNamespacedStyleName = (styleName: string, styleModuleImport
const moduleName = styleNameParts[1];

if (!moduleName) {
// eslint-disable-next-line no-console
console.log({
moduleName
});

throw new Error('Invalid style name.');
}

if (!styleModuleImportMap[importName]) {
// eslint-disable-next-line no-console
console.log({
importName
});

throw new Error('CSS module import does not exist.');
}

if (!styleModuleImportMap[importName][moduleName]) {
// eslint-disable-next-line no-console
console.log({
importName,
moduleName
});

throw new Error('CSS module does not exist.');
}

Expand Down Expand Up @@ -56,7 +72,12 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM
const styleModuleMap: StyleModuleMapType = styleModuleImportMap[styleModuleImportMapKeys[0]];

if (!styleModuleMap[styleName]) {
throw new Error('Could not resolve the styleName \'' + styleName + '\'.');
// eslint-disable-next-line no-console
console.log({
styleName
});

throw new Error('Could not resolve a styleName.');
}

return styleModuleMap[styleName];
Expand Down