p-catch-if
有条件的承诺捕获处理程序
仅用于处理某些类型的错误,让其他错误通过时很有用。
安装
$ npm install p-catch-if
用法
import pCatchIf from 'p-catch-if' ;
// Error constructor
getData ( ) . catch ( pCatchIf ( TimeoutError , ( ) => retry ( getData ) ) ) ;
// Multiple error constructors
getData ( ) . catch ( pCatchIf ( [ NetworkError , TimeoutError ] , ( ) => retry ( getData ) ) ) ;
// Boolean
getData ( ) . catch ( pCatchIf ( isProduct
评论0
最新资源