SimpleConnector 异常错误使用 makeException
This commit is contained in:
parent
a0b607bf6d
commit
1e488d86cb
|
|
@ -42,7 +42,7 @@ function judgeRelation(schema, entity, attr, allowUnrecognized) {
|
|||
}
|
||||
else {
|
||||
// 这种情况应该不会跑到
|
||||
(0, assert_1.default)(false);
|
||||
(0, assert_1.default)(false, `非法的属性名:[${attr}]`);
|
||||
}
|
||||
}
|
||||
else if ((attributes.hasOwnProperty(`${attr}Id`))) {
|
||||
|
|
|
|||
|
|
@ -87,15 +87,3 @@ export type DependencyConfiguration = string[];
|
|||
export type RenderConfiguration<ED extends BaseEntityDict & EntityDict> = {
|
||||
styleDict: StyleDict<ED>;
|
||||
};
|
||||
/**
|
||||
* 编译环境配置
|
||||
*/
|
||||
export type CompilerConfiguration = {
|
||||
webpack?: {
|
||||
resolve?: {
|
||||
alias?: Record<string, string>;
|
||||
fallback?: Record<string, string | false>;
|
||||
};
|
||||
extraOakModules?: (string | RegExp)[];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class SimpleConnector {
|
|||
async parseAspectResult(response) {
|
||||
if (response.status > 299) {
|
||||
const err = new types_1.OakServerProxyException(`网络请求返回status是${response.status}`);
|
||||
throw err;
|
||||
throw this.makeException(err);
|
||||
}
|
||||
const message = response.headers.get('oak-message');
|
||||
const responseType = response.headers.get('Content-Type') ||
|
||||
|
|
@ -118,10 +118,14 @@ class SimpleConnector {
|
|||
}
|
||||
catch (err) {
|
||||
// fetch返回异常一定是网络异常
|
||||
let exception = err;
|
||||
if (err instanceof types_1.OakRequestTimeoutException) {
|
||||
throw new types_1.OakNetworkException(`接口请求超时`);
|
||||
exception = new types_1.OakNetworkException(`接口请求超时`);
|
||||
}
|
||||
throw new types_1.OakNetworkException(`接口请求时发生网络异常`);
|
||||
else {
|
||||
exception = new types_1.OakNetworkException(`接口请求时发生网络异常`);
|
||||
}
|
||||
throw this.makeException(exception);
|
||||
}
|
||||
return this.parseAspectResult(response);
|
||||
}
|
||||
|
|
@ -143,14 +147,18 @@ class SimpleConnector {
|
|||
response = await this.fetchWithTimeout(this.serverSubscribePointUrl, {}, this.timeout);
|
||||
}
|
||||
catch (err) {
|
||||
let exception = err;
|
||||
if (err instanceof types_1.OakRequestTimeoutException) {
|
||||
throw new types_1.OakNetworkException(`接口请求超时`);
|
||||
exception = new types_1.OakNetworkException(`接口请求超时`);
|
||||
}
|
||||
throw new types_1.OakNetworkException(`接口请求时发生网络异常`);
|
||||
else {
|
||||
exception = new types_1.OakNetworkException(`接口请求时发生网络异常`);
|
||||
}
|
||||
throw this.makeException(exception);
|
||||
}
|
||||
if (response.status > 299) {
|
||||
const err = new types_1.OakServerProxyException(`网络请求返回status是${response.status}`);
|
||||
throw err;
|
||||
throw this.makeException(err);
|
||||
}
|
||||
const message = response.headers.get('oak-message');
|
||||
const responseType = response.headers.get('Content-Type') ||
|
||||
|
|
@ -219,10 +227,6 @@ class SimpleConnector {
|
|||
* @param headers
|
||||
*/
|
||||
makeBridgeUrl(url, headers) {
|
||||
// if (process.env.PROD !== 'true') {
|
||||
// console.warn('在development下无法通过bridge访问资源,将直接访问,可能失败', url);
|
||||
// return url;
|
||||
// }
|
||||
const encodeUrl = encodeURIComponent(url);
|
||||
return `${this.serverBridgeUrl}?url=${encodeUrl}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export default class SimpleConnector<ED extends EntityDict & BaseEntityDict, Fro
|
|||
const err = new OakServerProxyException(
|
||||
`网络请求返回status是${response.status}`
|
||||
);
|
||||
throw err;
|
||||
throw this.makeException(err);
|
||||
}
|
||||
|
||||
const message = response.headers.get('oak-message');
|
||||
|
|
@ -133,10 +133,14 @@ export default class SimpleConnector<ED extends EntityDict & BaseEntityDict, Fro
|
|||
}, this.timeout);
|
||||
} catch (err) {
|
||||
// fetch返回异常一定是网络异常
|
||||
let exception = err;
|
||||
if (err instanceof OakRequestTimeoutException) {
|
||||
throw new OakNetworkException(`接口请求超时`);
|
||||
exception = new OakNetworkException(`接口请求超时`);
|
||||
}
|
||||
throw new OakNetworkException(`接口请求时发生网络异常`);
|
||||
else {
|
||||
exception = new OakNetworkException(`接口请求时发生网络异常`);
|
||||
}
|
||||
throw this.makeException(exception);
|
||||
}
|
||||
|
||||
return this.parseAspectResult(response);
|
||||
|
|
@ -163,17 +167,21 @@ export default class SimpleConnector<ED extends EntityDict & BaseEntityDict, Fro
|
|||
try {
|
||||
response = await this.fetchWithTimeout(this.serverSubscribePointUrl, {}, this.timeout);
|
||||
} catch (err) {
|
||||
let exception = err;
|
||||
if (err instanceof OakRequestTimeoutException) {
|
||||
throw new OakNetworkException(`接口请求超时`);
|
||||
exception = new OakNetworkException(`接口请求超时`);
|
||||
}
|
||||
throw new OakNetworkException(`接口请求时发生网络异常`);
|
||||
else {
|
||||
exception = new OakNetworkException(`接口请求时发生网络异常`);
|
||||
}
|
||||
throw this.makeException(exception);
|
||||
}
|
||||
|
||||
if (response.status > 299) {
|
||||
const err = new OakServerProxyException(
|
||||
`网络请求返回status是${response.status}`
|
||||
);
|
||||
throw err;
|
||||
throw this.makeException(err);
|
||||
}
|
||||
|
||||
const message = response.headers.get('oak-message');
|
||||
|
|
@ -261,10 +269,6 @@ export default class SimpleConnector<ED extends EntityDict & BaseEntityDict, Fro
|
|||
* @param headers
|
||||
*/
|
||||
makeBridgeUrl(url: string, headers?: Record<string, string>) {
|
||||
// if (process.env.PROD !== 'true') {
|
||||
// console.warn('在development下无法通过bridge访问资源,将直接访问,可能失败', url);
|
||||
// return url;
|
||||
// }
|
||||
const encodeUrl = encodeURIComponent(url);
|
||||
|
||||
return `${this.serverBridgeUrl}?url=${encodeUrl}`;
|
||||
|
|
|
|||
Loading…
Reference in New Issue