Add an assertion when updating conversations; update cleanData

This commit is contained in:
Evan Hahn 2021-02-04 13:54:03 -06:00 committed by GitHub
parent 73a304faba
commit bc37b5c907
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 749 additions and 79 deletions

21
ts/util/assert.ts Normal file
View file

@ -0,0 +1,21 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { getEnvironment, Environment } from '../environment';
import * as log from '../logging/log';
/**
* In production, logs an error and continues. In all other environments, throws an error.
*/
export function assert(condition: unknown, message: string): asserts condition {
if (!condition) {
const err = new Error(message);
if (getEnvironment() !== Environment.Production) {
if (getEnvironment() === Environment.Development) {
debugger; // eslint-disable-line no-debugger
}
throw err;
}
log.error(err);
}
}