UNPKG

uview-next

Version:

基于uView UI 2.0,110+高质量组件库,支持vue2和vue3,支持鸿蒙,支持多语言,搭配便捷工具助力,让开发更得心应手

40 lines (33 loc) 660 B
/*eslint no-console: 0 */ class ErrorHandler{ constructor(api){ this.api = api; } handleCatch(e){ // If babel supported extending of Error in a correct way instanceof would be used here if(e.name === "InvalidInputException"){ if(this.api._options.valid !== this.api._defaults.valid){ this.api._options.valid(false); } else{ throw e.message; } } else{ throw e; } this.api.render = function(){}; } wrapBarcodeCall(func){ try{ var result = func(...arguments); this.api._options.valid(true); return result; } catch(e){ this.handleCatch(e); return this.api; } } } export default ErrorHandler;