nl_tokens: Invoke a function expecting an error to be thrown . If an error is not thrown call cb with an error and return a rejected Promise .
pl_tokens: function catchAndMatch ( fn , matcher , cb ) { return isIllegalArguments ( { fn : fn , matcher : matcher , cb : cb } ) . then ( fn , function ( err ) { throw err ; } ) . then ( function ( ) { // If we got here the function did not throw an error var error = new Error ( 'No error thrown' ) ; if ( cb ) cb ( error ) ; return Promise . reject ( error ) ; } , function ( err ) { // Error was thrown - check that it satisfies the matcher if ( doesMatch ( { matcher : matcher , err : err } ) ) { if ( cb ) cb ( ) ; return Promise . resolve ( ) ; } var error = new Error ( 'Error does not satisfy matcher' ) ; if ( cb ) cb ( <mask> ) ; return Promise . reject ( error ) ; } ) ; }