# SIDE_EFFECT ### Synopsis Perform some action and continue with the handler chain using the current error or immediately throw the error thrown by the callback. ### Description This handler allows execution of a callback, anticipating that it might fail. If it does, the error from the callback is thrown immediately. If the callback executes without errors, the current error is propagated to the next handler in the chain. ### Options The following options are supported. - `callback: (error, ...parameters) => void | Promise` _(mandatory)_ The callback is invoked with the same context as the wrapped function (unless you use an arrow function). - `scope: Class` _(optional)_ Limit the handler to exceptions of the given class (or any subclass thereof). - `predicate: (error, ...parameters) => boolean | Promise` _(optional)_ Dynamically skip invocation of the handler depending on the error thrown or any of the wrapped method's parameters. The predicate is invoked with the same context as the wrapped function (unless you use an arrow function). - `onCallbackError: CallbackErrorAction` _(optional, defaults to `THROW_WRAPPED`)_ This option controls how errors thrown by the callback are handled. - `THROW_WRAPPED`: The error is wrapped in an `MapError`. This is the default. - `THROW`: The error is thrown as-is. - `THROW_TRIGGER`: The error is ignored and the triggering error is thrown instead. ### Example ```typescript class Foo { @HandleError({ action: HandlerAction.SIDE_EFFECT, // Let's assume the database library knows how to serialize errors ;) callback: error => this.database.insert('errors', error), }) public async doSomething(): Promise { // log all errors thrown here to the database (and fail if the insertion fails) } } ```