@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
13 lines (12 loc) • 815 B
TypeScript
import type { ValueOrProvider } from '../misc/functions';
/**
* `@safe` decorator: wraps a method or getter in try/catch and returns a fallback value on synchronous error.
* - Supports static or provider fallback (ValueOrProvider)
* - Invokes instance hook `$$error(error, name, original)` before returning fallback
* - Only handles synchronous throws (async rejections pass through)
*
* @param fallback - value or provider used when the original function throws (default: null)
* @throws Error when applied to a non-function / non-getter
*/
export declare function safe<R>(fallback: ValueOrProvider<R>): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<R> | TypedPropertyDescriptor<(...args: any[]) => R>) => void;
export declare function safe(): MethodDecorator & PropertyDecorator;