|
@@ -4,7 +4,7 @@ import { RequestBase } from '../interface/proxy.interface';
|
|
|
import { get, lowerCase, omit, pick } from 'lodash';
|
|
|
import { HttpServiceFactory, HttpService } from '@midwayjs/axios';
|
|
|
import { PemService } from './pem.service';
|
|
|
-import { ServiceError } from '../error/service.error';
|
|
|
+import { ErrorCode, ServiceError } from '../error/service.error';
|
|
|
@Provide()
|
|
|
export class ProxyService {
|
|
|
@Inject()
|
|
@@ -99,15 +99,16 @@ export class ProxyService {
|
|
|
let result;
|
|
|
try {
|
|
|
const res = await this.serviceAxios.request(reqConfig);
|
|
|
- if (res.status !== 200) throw new Error('proxy service request error');
|
|
|
+ if (res.status !== 200) throw new ServiceError(ErrorCode.REQUSET_ERROR);
|
|
|
result = res.data;
|
|
|
} catch (error) {
|
|
|
// 请求不是自定义的错误,把错误隐藏,写到日志中
|
|
|
this.ctx.logger.error(error.stack);
|
|
|
- return {
|
|
|
- errmsg: 'proxy service request error',
|
|
|
- code: get(error, 'response.status'),
|
|
|
- };
|
|
|
+ throw new ServiceError(ErrorCode.REQUSET_ERROR);
|
|
|
+ // return {
|
|
|
+ // errmsg: 'proxy service request error',
|
|
|
+ // errcode: get(error, 'response.status'),
|
|
|
+ // };
|
|
|
}
|
|
|
if (result.errcode === 0) {
|
|
|
if (this.useCrypto) {
|