UNPKG

zmp-sdk

Version:

Zalo Mini App SDK

2 lines (1 loc) 959 B
import t from'./../external/@swc/helpers/src/_class_call_check.mjs.js';import s from'./../external/@swc/helpers/src/_instanceof.mjs.js';import e from"./lodash.js";import{RESPONSE_CODE as o,MESSAGES as i}from"../constants.js";var n=function(){function s(e,o,i,n){t(this,s),this.code=e,this.message=o,this.api=i,this.detail=n}var e=s.prototype;return e.toString=function(){return"api: ".concat(String(this.api),"; code: ").concat(this.code,"; message: ").concat(JSON.stringify(this.message))},e.toJSON=function(){return{code:this.code,message:this.message,api:this.api,detail:this.detail}},s}(),r=function(t,r){return s(t,n)?function(t,s){return t.api=s,t.toJSON()}(t,r):function(t,r){return s(t,Error)?new n(o.UNKNOWN_ERROR,t.message,r).toJSON():e.isEmpty(null==t?void 0:t.message)||e.isEmpty(null==t?void 0:t.code)?new n(o.UNKNOWN_ERROR,i.UNKNOWN_ERROR,r,t).toJSON():new n(t.code,t.message,r,t.detail).toJSON()}(t,r)};export{n as AppError,r as errorHandler};