mirror of
https://github.com/denoland/std.git
synced 2024-11-21 12:40:03 +00:00
refactor(internal): align additional error messages (#5766)
This commit is contained in:
parent
8f3dd6ef0b
commit
7fb685efff
@ -77,7 +77,9 @@ export function assertFp(value: unknown): asserts value is FarthestPoint {
|
||||
typeof (value as FarthestPoint)?.y !== "number" ||
|
||||
typeof (value as FarthestPoint)?.id !== "number"
|
||||
) {
|
||||
throw new Error("Unexpected missing FarthestPoint");
|
||||
throw new Error(
|
||||
`Unexpected value, expected 'FarthestPoint': received ${typeof value}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,11 +134,26 @@ Deno.test({
|
||||
Deno.test({
|
||||
name: "assertFp() throws",
|
||||
fn() {
|
||||
const error = "Unexpected missing FarthestPoint";
|
||||
assertThrows(() => assertFp({ id: 0 }), Error, error);
|
||||
assertThrows(() => assertFp({ y: 0 }), Error, error);
|
||||
assertThrows(() => assertFp(undefined), Error, error);
|
||||
assertThrows(() => assertFp(null), Error, error);
|
||||
assertThrows(
|
||||
() => assertFp({ id: 0 }),
|
||||
Error,
|
||||
"Unexpected value, expected 'FarthestPoint': received object",
|
||||
);
|
||||
assertThrows(
|
||||
() => assertFp({ y: 0 }),
|
||||
Error,
|
||||
"Unexpected value, expected 'FarthestPoint': received object",
|
||||
);
|
||||
assertThrows(
|
||||
() => assertFp(undefined),
|
||||
Error,
|
||||
"Unexpected value, expected 'FarthestPoint': received undefined",
|
||||
);
|
||||
assertThrows(
|
||||
() => assertFp(null),
|
||||
Error,
|
||||
"Unexpected value, expected 'FarthestPoint': received object",
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user