package ppos

import (
	"PPOSUtils/utils"
	"errors"
)

func ThrowException(code int64, errSlice ...interface{}) utils.UtilsException {
	return utils.ThrowException(code, errSlice...)
}

func parse(mp utils.Mp) interface{} {
	if !mp.Has("error_code") || !mp.Has("error_msg") {
		return ThrowException(40005001, errors.New("接口请求失败！ "))
	}
	if _errorCode, _ := mp.String("error_code"); _errorCode != "0" {
		return ThrowException(40005002, errors.New(mp.DefaultString("error_msg", "")))
	}
	if !mp.Has("result") {
		return ThrowException(40005003, errors.New("接口请求失败！ "))
	}
	return mp.Get("result")
}
