72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.StartPayFailure = exports.PayUnRefundable = exports.RefundExceedMax = exports.ExternalPayUtilException = exports.UploadShipException = void 0;
|
|
exports.makeException = makeException;
|
|
const tslib_1 = require("tslib");
|
|
const types_1 = require("oak-domain/lib/types");
|
|
const DependentExceptions_1 = tslib_1.__importDefault(require("./DependentExceptions"));
|
|
class UploadShipException extends types_1.OakException {
|
|
constructor(message) {
|
|
super(message || '调用发货接口失败');
|
|
}
|
|
}
|
|
exports.UploadShipException = UploadShipException;
|
|
class ExternalPayUtilException extends types_1.OakException {
|
|
reason;
|
|
constructor(reason, message, _module, params) {
|
|
super(message || 'error::pay.externalException', _module || 'oak-pay-business', params);
|
|
this.reason = reason;
|
|
}
|
|
getSerialData() {
|
|
const data = super.getSerialData();
|
|
return {
|
|
...data,
|
|
reason: this.reason,
|
|
};
|
|
}
|
|
}
|
|
exports.ExternalPayUtilException = ExternalPayUtilException;
|
|
class RefundExceedMax extends types_1.OakException {
|
|
constructor(message, _module, params) {
|
|
super(message || 'error::refund.create.exceedMax', _module || 'oak-pay-business', params);
|
|
}
|
|
}
|
|
exports.RefundExceedMax = RefundExceedMax;
|
|
class PayUnRefundable extends types_1.OakException {
|
|
constructor(message, _module, params) {
|
|
super(message || 'error::refund.create.payUnrefundable', _module || 'oak-pay-business', params);
|
|
}
|
|
}
|
|
exports.PayUnRefundable = PayUnRefundable;
|
|
class StartPayFailure extends types_1.OakException {
|
|
constructor(message, _module, params) {
|
|
super(message, _module || 'oak-pay-business', params);
|
|
}
|
|
}
|
|
exports.StartPayFailure = StartPayFailure;
|
|
function makeException(msg) {
|
|
const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
|
let exception = (0, DependentExceptions_1.default)(data);
|
|
if (exception) {
|
|
return exception;
|
|
}
|
|
const { name, message } = data;
|
|
switch (name) {
|
|
case 'ExternalPrePayException': {
|
|
exception = new ExternalPayUtilException(data.reason, message);
|
|
break;
|
|
}
|
|
case 'RefundExceedMax': {
|
|
exception = new RefundExceedMax(message);
|
|
break;
|
|
}
|
|
default: {
|
|
break;
|
|
}
|
|
}
|
|
if (exception) {
|
|
exception.setOpRecords(data.opRecords);
|
|
}
|
|
return exception;
|
|
}
|