Merge pull request #1135 from gap777/add_more_detail_in_error_thrown_by_to

Improve debugging support
This commit is contained in:
Jos de Jong 2018-06-17 14:15:08 +02:00 committed by GitHub
commit 78f882ef24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -801,7 +801,7 @@ function factory (type, config, load, typed, math) {
// other = new Unit(null, valuelessUnit)
other = Unit.parse(valuelessUnit)
if (!this.equalBase(other)) {
throw new Error('Units do not match')
throw new Error(`Units do not match ('${other.toString()}' != '${this.toString()}')`)
}
if (other.value !== null) {
throw new Error('Cannot convert to a unit with a value')
@ -813,7 +813,7 @@ function factory (type, config, load, typed, math) {
return other
} else if (type.isUnit(valuelessUnit)) {
if (!this.equalBase(valuelessUnit)) {
throw new Error('Units do not match')
throw new Error(`Units do not match ('${valuelessUnit.toString()}' != '${this.toString()}')`)
}
if (valuelessUnit.value !== null) {
throw new Error('Cannot convert to a unit with a value')