Skip to content

Made it easier to debug mistakes #179

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

Merged
merged 1 commit into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/createObjectExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const createObjectExpression = (t: BabelTypes, object: InputObjectType): ObjectE
} else if (typeof value === 'boolean') {
newValue = t.booleanLiteral(value);
} else {
throw new TypeError('Unexpected type.');
throw new TypeError('Unexpected type: ' + typeof value);
}

properties.push(
Expand Down
18 changes: 10 additions & 8 deletions src/getClassName.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,32 @@ const getClassNameForNamespacedStyleName = (

if (!moduleName) {
if (handleMissingStyleName === 'throw') {
throw new Error('Invalid style name.');
throw new Error('Invalid style name: ' + styleName);
} else if (handleMissingStyleName === 'warn') {
// eslint-disable-next-line no-console
console.warn('Invalid style name.');
console.warn('Invalid style name: ' + styleName);
} else {
return null;
}
}

if (!styleModuleImportMap[importName]) {
if (handleMissingStyleName === 'throw') {
throw new Error('CSS module import does not exist.');
throw new Error('CSS module import does not exist: ' + importName);
} else if (handleMissingStyleName === 'warn') {
// eslint-disable-next-line no-console
console.warn('CSS module import does not exist.');
console.warn('CSS module import does not exist: ' + importName);
} else {
return null;
}
}

if (!styleModuleImportMap[importName][moduleName]) {
if (handleMissingStyleName === 'throw') {
throw new Error('CSS module does not exist.');
throw new Error('CSS module does not exist: ' + moduleName);
} else if (handleMissingStyleName === 'warn') {
// eslint-disable-next-line no-console
console.warn('CSS module does not exist.');
console.warn('CSS module does not exist: ' + moduleName);
} else {
return null;
}
Expand Down Expand Up @@ -83,11 +83,13 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM
}

if (styleModuleImportMapKeys.length === 0) {
throw new Error('Cannot use styleName attribute without importing at least one stylesheet.');
throw new Error('Cannot use styleName attribute for style name \'' + styleName +
'\' without importing at least one stylesheet.');
}

if (styleModuleImportMapKeys.length > 1) {
throw new Error('Cannot use anonymous style name with more than one stylesheet import.');
throw new Error('Cannot use anonymous style name \'' + styleName +
'\' with more than one stylesheet import.');
}

const styleModuleMap: StyleModuleMapType = styleModuleImportMap[styleModuleImportMapKeys[0]];
Expand Down
2 changes: 1 addition & 1 deletion src/replaceJsxExpressionContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default (
)
));
} else {
throw new Error('Unexpected attribute value.');
throw new Error('Unexpected attribute value: ' + destinationAttribute.value);
}
} else {
path.node.openingElement.attributes.push(jSXAttribute(
Expand Down
2 changes: 1 addition & 1 deletion src/resolveStringLiteral.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default (
stringLiteral(resolvedStyleName)
);
} else {
throw new Error('Unexpected attribute value.');
throw new Error('Unexpected attribute value:' + destinationAttribute.value);
}

path.node.openingElement.attributes.splice(path.node.openingElement.attributes.indexOf(sourceAttribute), 1);
Expand Down