23 lines
675 B
TypeScript
23 lines
675 B
TypeScript
// Copyright (C) 2026 Whiterun LLC,
|
|
// This software is licensed under the GNU Lesser General Public License (LGPL), version 3.0 or later.
|
|
// A copy of the license can be found in the LICENSE file or at https://www.gnu.org/licenses/lgpl-3.0.html
|
|
|
|
/**
|
|
* Minimal primitives shim — replaces @riftenlabs/primitives.
|
|
*/
|
|
|
|
export const throwUnless = (x: boolean, what: string): void => {
|
|
if (!x) {
|
|
throw Error(`Internal application error: ${what}`);
|
|
}
|
|
};
|
|
|
|
export function unwrap<T>(value: string | Error | T): T {
|
|
if (typeof value === "string") {
|
|
throw new Error(`unwrap: ${value}`);
|
|
}
|
|
if (value instanceof Error) {
|
|
throw value;
|
|
}
|
|
return value as T;
|
|
}
|