Skip to content

Commit

Permalink
Polish error messages (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi committed May 23, 2017
1 parent a294ae2 commit 6e6df4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
16 changes: 7 additions & 9 deletions packages/babel-plugin-minify-mangle-names/src/index.js
Expand Up @@ -153,10 +153,9 @@ module.exports = babel => {
// This should NOT happen ultimately. Panic if this code block is
// reached
throw new Error(
"Binding not found for ReferencedIdentifier. " +
name +
"Please report this at " +
newIssueUrl
`Binding not found for ReferencedIdentifier "${name}" ` +
`present in "${path.parentPath.type}". ` +
`Please report this at ${newIssueUrl}`
);
} else {
// Add it to our scope tracker if everything is fine
Expand Down Expand Up @@ -188,10 +187,9 @@ module.exports = babel => {

// This should NOT happen ultimately. Panic if this code is reached
throw new Error(
"Binding not found for BindingIdentifier. " +
name +
"Please report this at " +
newIssueUrl
`Binding not found for BindingIdentifier "${name}" ` +
`present in "${path.parentPath.type}". ` +
`Please report this at ${newIssueUrl}`
);
}

Expand Down Expand Up @@ -480,7 +478,7 @@ module.exports = babel => {
} else {
throw new Error(
`Unexpected Rename Error: ` +
`Trying to replace ${node.name}: from ${oldName} to ${newName}` +
`Trying to replace "${node.name}": from "${oldName}" to "${newName}". ` +
`Please report it at ${newIssueUrl}`
);
}
Expand Down
14 changes: 6 additions & 8 deletions packages/babel-plugin-minify-mangle-names/src/scope-tracker.js
Expand Up @@ -42,7 +42,7 @@ module.exports = class ScopeTracker {
this.references.get(parent).add(name);
if (!binding) {
throw new Error(
`Binding Not Found for ${name} during scopeTracker.addRefernce: ` +
`Binding Not Found for ${name} during scopeTracker.addRefernce. ` +
`Please report at ${newIssueUrl}`
);
}
Expand Down Expand Up @@ -83,8 +83,8 @@ module.exports = class ScopeTracker {
if (!binding) {
// Something went wrong - panic
throw new Error(
"Binding Not Found during scopeTracker.updateRefernce: " +
`Updating "${oldName}" to "${newName}"` +
"Binding Not Found during scopeTracker.updateRefernce " +
`while updating "${oldName}" to "${newName}". ` +
`Please report at ${newIssueUrl}`
);
}
Expand Down Expand Up @@ -167,11 +167,9 @@ module.exports = class ScopeTracker {

if (existingBinding && existingBinding !== binding) {
throw new Error(
"Binding " +
existingBinding.identifier.name +
"already exists. " +
"Trying to add " +
binding.identifier.name
`scopeTracker.addBinding: ` +
`Binding "${existingBinding.identifier.name}" already exists. ` +
`Trying to add "${binding.identifier.name}" again.`
);
}

Expand Down

0 comments on commit 6e6df4b

Please sign in to comment.