Skip to content

Commit c05bc2d

Browse files
committed
fix: 🐛 correct error message in UnitSystem#convert
1 parent 4cda25a commit c05bc2d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/UnitSystem/UnitSystem.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ class UnitSystem {
7878
);
7979
}
8080
if (!(endUnit instanceof Unit)) {
81-
throw new TypeError('Expected a Unit, got "{"name":"inch"}" instead');
81+
throw new TypeError(
82+
`Expected a Unit, got "${JSON.stringify(endUnit)}" instead`
83+
);
8284
}
8385
if (measurement.unit === endUnit) {
8486
return measurement;

src/UnitSystem/UnitSystem.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe(UnitSystem, () => {
145145
expect(() => {
146146
system.convert(new Measurement(12, inch), { name: 'foot' });
147147
}).toThrowError(
148-
new TypeError('Expected a Unit, got "{"name":"inch"}" instead')
148+
new TypeError('Expected a Unit, got "{"name":"foot"}" instead')
149149
);
150150
});
151151
});

0 commit comments

Comments
 (0)