diff --git a/src/createObjectExpression.js b/src/createObjectExpression.js index 3227afa..8af0164 100644 --- a/src/createObjectExpression.js +++ b/src/createObjectExpression.js @@ -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( diff --git a/src/getClassName.js b/src/getClassName.js index a987748..421787a 100644 --- a/src/getClassName.js +++ b/src/getClassName.js @@ -28,10 +28,10 @@ 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; } @@ -39,10 +39,10 @@ const getClassNameForNamespacedStyleName = ( 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; } @@ -50,10 +50,10 @@ const getClassNameForNamespacedStyleName = ( 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; } @@ -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]]; diff --git a/src/replaceJsxExpressionContainer.js b/src/replaceJsxExpressionContainer.js index e7ca0f5..f520c7e 100644 --- a/src/replaceJsxExpressionContainer.js +++ b/src/replaceJsxExpressionContainer.js @@ -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( diff --git a/src/resolveStringLiteral.js b/src/resolveStringLiteral.js index 796bbfe..55925ab 100644 --- a/src/resolveStringLiteral.js +++ b/src/resolveStringLiteral.js @@ -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);