module author Surmon <https://github.com/surmon-china>
  import { isFunction , isPromise } from './utils' ; const VEACT_NAME = 'veact' ; const LOGGER_PREFIX = `[${ VEACT_NAME }]` ; export const logger = { ... console , log ( ... args ) { console . log ( LOGGER_PREFIX , ... args ) ; } , warn ( ... args ) { console . warn ( LOGGER_PREFIX , ... args ) ; } , error ( ... args ) { console . error ( LOGGER_PREFIX , ... args ) ; } , } ; export function callWithErrorHandling ( fn , errorString , args ? ) { let result ; try { result = args ? fn ( ... args ) : fn ( ) ; } catch ( error ) { logger . error ( error , errorString ) ; } return result ; } export function callWithAsyncErrorHandling ( fn , errorString , args ? ) { if ( isFunction ( fn ) ) { const result = callWithErrorHandling ( fn , errorString , args ) ; if ( result && isPromise ( result ) ) { result . catch ( ( error ) => { logger . error ( error , errorString ) ; } ) ; } return result ; } const values = [ ] ; for ( let i = 0 ; i < fn . length ; i ++ ) { values . push ( callWithAsyncErrorHandling ( fn [ i ] , errorString , args ) ) ; } return values ; }