ente/web/packages/base/assert.ts
Manav Rathi 0d079fc593
Clean
2024-09-11 09:21:07 +05:30

16 lines
462 B
TypeScript

import { isDevBuild } from "./env";
import log from "./log";
/**
* If running in a dev build, throw an exception with the given message.
* Otherwise log it as a warning.
*
* @param message An optional message to use for the failure. If not provided,
* then a generic one is used.
*/
export const assertionFailed = (message?: string) => {
message = message ?? "Assertion failed";
if (isDevBuild) throw new Error(message);
log.warn(message);
};