mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +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)?.y !== "number" ||
|
||||||
typeof (value as FarthestPoint)?.id !== "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({
|
Deno.test({
|
||||||
name: "assertFp() throws",
|
name: "assertFp() throws",
|
||||||
fn() {
|
fn() {
|
||||||
const error = "Unexpected missing FarthestPoint";
|
assertThrows(
|
||||||
assertThrows(() => assertFp({ id: 0 }), Error, error);
|
() => assertFp({ id: 0 }),
|
||||||
assertThrows(() => assertFp({ y: 0 }), Error, error);
|
Error,
|
||||||
assertThrows(() => assertFp(undefined), Error, error);
|
"Unexpected value, expected 'FarthestPoint': received object",
|
||||||
assertThrows(() => assertFp(null), Error, error);
|
);
|
||||||
|
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