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