mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 09:08:34 +00:00
Show detailed errors from the invariant function (in production)
This commit is contained in:
parent
01e47d7a1d
commit
4a0c68eacb
1 changed files with 1 additions and 10 deletions
|
|
@ -8,11 +8,9 @@ export function cleanRequestId(requestId?: string | string[] | null): string | u
|
|||
}
|
||||
}
|
||||
|
||||
const isProduction: boolean = process.env.NODE_ENV === 'production';
|
||||
const prefix = 'Invariant failed';
|
||||
|
||||
// Throw an error if the condition fails
|
||||
// Strip out error messages for production
|
||||
// > Not providing an inline default argument for message as the result is smaller
|
||||
export function invariant(
|
||||
condition: unknown,
|
||||
|
|
@ -25,14 +23,7 @@ export function invariant(
|
|||
}
|
||||
// Condition not passed
|
||||
|
||||
// In production we strip the message but still throw
|
||||
if (isProduction) {
|
||||
throw new Error(prefix);
|
||||
}
|
||||
|
||||
// When not in production we allow the message to pass through
|
||||
// *This block will be removed in production builds*
|
||||
|
||||
// We allow the message to pass through
|
||||
const provided: string | undefined = typeof message === 'function' ? message() : message;
|
||||
|
||||
// Options:
|
||||
|
|
|
|||
Loading…
Reference in a new issue