import { sendException } from "../services/analytics" ; type PromiseProducer < TR > = ( ... args : any [ ] ) => Promise < TR > ; type PromiseProducerParams < TR , TF extends PromiseProducer < TR > > = TF extends ( ... args : infer P ) => Promise < TR > ? P : never ; export const promiseRejectionHandler = < TR , TProducer extends PromiseProducer < TR > > ( promiseProducer ) : PromiseProducer < void > => { return ( ... args ) => promiseProducer ( ... args ) . catch ( err => { sendException ( err ) ; } ) . then ( ) ; } ;