import { log_error } from "./Log" ; export class TemplaterError extends Error { constructor ( msg , public console_msg ? ) { super ( msg ) ; this . name = this . constructor . name ; Error . captureStackTrace ( this , this . constructor ) ; } } export async function errorWrapper < T > ( fn , msg ) { try { return await fn ( ) ; } catch ( e ) { if ( ! ( e instanceof TemplaterError ) ) { log_error ( new TemplaterError ( msg , e . message ) ) ; } else { log_error ( e ) ; } return null ; } } export function errorWrapperSync < T > ( fn , msg ) { try { return fn ( ) ; } catch ( e ) { log_error ( new TemplaterError ( msg , e . message ) ) ; return null ; } }