import type { Nullable } from "@util/Nullable"; type ErrType = { new(msg?: string): T } export function unwrap_err(result: Nullable, errType: ErrType, errMsg?: string): T { if (result === null || result === undefined) { throw new errType(errMsg); } return result; }