function ok_or<T>(x: T | null, msg: string): T { if (x === null) throw new Error(msg); return x; }
function ok_or<T>(x: T | null, msg: string): T | Error { if (x === null) return new Error(msg); return x; }