"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hightOrderSdk=exports.AbstractSdk=void 0;const request_error_1=require("../request-error"),compile_error_1=require("../compile-error");class AbstractSdk{exec(r,e,t){return this[r](e,t)}}function errorHandler(r){return(0,request_error_1.isRequestError)(r)||(0,compile_error_1.isCompileError)(r)?{type:r.type,message:JSON.stringify(r.IPCFormat())}:void 0===r||r instanceof Error?{message:r?r.stack||r.message:"default catch"}:r}function hightOrderSdk(r,e=errorHandler){return(t,s,o)=>{try{const e=r.exec(t,s,o);e instanceof Promise?e.then(r=>o.invoke(s.success,r),r=>o.invoke(s.fail,errorHandler(r))):o.invoke(s.success,e)}catch(r){o.invoke(s.fail,e(r))}}}exports.AbstractSdk=AbstractSdk,exports.hightOrderSdk=hightOrderSdk;