Soft assert for hydrating story context

This commit is contained in:
Josh Perez 2022-05-11 19:47:19 -04:00 committed by GitHub
parent a924591a8c
commit ddde85cdd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View file

@ -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.
*/