Soft assert for hydrating story context
This commit is contained in:
parent
a924591a8c
commit
ddde85cdd8
3 changed files with 24 additions and 5 deletions
|
@ -4,6 +4,21 @@
|
|||
import { getEnvironment, Environment } from '../environment';
|
||||
import * as log from '../logging/log';
|
||||
|
||||
/**
|
||||
* In production and beta, logs a warning and continues. For development it
|
||||
* starts the debugger.
|
||||
*/
|
||||
export function softAssert(condition: unknown, message: string): void {
|
||||
if (!condition) {
|
||||
if (getEnvironment() === Environment.Development) {
|
||||
debugger; // eslint-disable-line no-debugger
|
||||
}
|
||||
|
||||
const err = new Error(message);
|
||||
log.warn('softAssert failure:', err && err.stack ? err.stack : err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* In production, logs an error and continues. In all other environments, throws an error.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue