mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Improve wait(...) input validation error message
This commit is contained in:
parent
787d6ecce4
commit
48a5b07a31
@ -110,10 +110,10 @@ export function ignoreUnhandledRejection<T extends Promise<any>>(promise: T): T
|
||||
|
||||
export async function wait(ms: number) {
|
||||
if (!Number.isFinite(ms) || ms < 0) {
|
||||
throw new StackAssertionError("wait() requires a non-negative integer number of milliseconds to wait.");
|
||||
throw new StackAssertionError(`wait() requires a non-negative integer number of milliseconds to wait. (found: ${ms}ms)`);
|
||||
}
|
||||
if (ms >= 2**31) {
|
||||
throw new StackAssertionError("The maximum timeout for wait() is 2147483647ms (2**31 - 1).");
|
||||
throw new StackAssertionError("The maximum timeout for wait() is 2147483647ms (2**31 - 1). (found: ${ms}ms)");
|
||||
}
|
||||
return await new Promise<void>(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user