dist/lib/driver.js
function asyncCall(method, params) {
    if (!Array.isArray(params))
        params = [params]; // cast to array for apply
    log_1.logger.info(`[${method}] Calling (async): ${JSON.stringify(params)}`);
    return Promise.resolve(exports.asteroid.apply(method, params).result)
        .catch((err) => {
        log_1.logger.error(`[${method}] Error:`, err);
        throw err; // throw after log to stop async chain
    })
        .then((result) => {
        (result)
            ? log_1.logger.debug(`[${method}] Success: ${JSON.stringify(result)}`)
            : log_1.logger.debug(`[${method}] Success`);
        return result;
    });
}
function asyncCall(method, params) {
    if (!Array.isArray(params))
        params = [params]; // cast to array for apply
    log_1.logger.info(`[${method}] Calling (async): ${JSON.stringify(params)}`);
    return Promise.resolve(exports.asteroid.apply(method, params).result)
        .catch((err) => {
        log_1.logger.error(`[${method}] Error:`, err);
        throw err; // throw after log to stop async chain
    })
        .then((result) => {
        (result)
            ? log_1.logger.debug(`[${method}] Success: ${JSON.stringify(result)}`)
            : log_1.logger.debug(`[${method}] Success`);
        return result;
    });
}
function asyncCall ( method , params ) { if ( ! Array . isArray ( params ) ) params = [ params ] ; // cast to array for apply log_1 . logger . info ( ` ${ method } ${ JSON . stringify ( params ) } ` ) ; return Promise . resolve ( exports . asteroid . apply ( method , params ) . result ) . catch ( ( err ) => { log_1 . logger . error ( ` ${ method } ` , err ) ; throw err ; // throw after log to stop async chain } ) . then ( ( result ) => { ( result ) ? log_1 . logger . debug ( ` ${ method } ${ JSON . stringify ( result ) } ` ) : log_1 . logger . debug ( ` ${ method } ` ) ; return result ; } ) ; }
Wraps method calls to ensure they return a Promise with caught exceptions.
@param method The Rocket.Chat server method, to call through Asteroid
@param params Single or array of parameters of the method to call
Wraps method calls to ensure they return a Promise with caught exceptions .