fix(frontend): preserve timeout label success toast
Build and publish Docker images / Build and publish images (push) Successful in 2m21s
Build and publish Docker images / Build and publish images (push) Successful in 2m21s
This commit is contained in:
@@ -133,7 +133,12 @@ const normalizeAPIErrorText = (message, status) => {
|
|||||||
if (/^(network error|failed to fetch|network request failed)$/i.test(text)) {
|
if (/^(network error|failed to fetch|network request failed)$/i.test(text)) {
|
||||||
return '网络连接失败,请检查网络后重试。';
|
return '网络连接失败,请检查网络后重试。';
|
||||||
}
|
}
|
||||||
if (/timeout|timed out|超时/i.test(text)) {
|
if (
|
||||||
|
/\b(?:timeout|timed out)\b/i.test(text) ||
|
||||||
|
/(?:^|(?:请求|连接|操作|网络|服务|服务器|上游)[^,。!?;;::]{0,8})超时(?:[,。!?;;::]|$)/.test(
|
||||||
|
text
|
||||||
|
)
|
||||||
|
) {
|
||||||
return '请求超时,请稍后再试。';
|
return '请求超时,请稍后再试。';
|
||||||
}
|
}
|
||||||
if (/^invalid email or password$/i.test(text)) {
|
if (/^invalid email or password$/i.test(text)) {
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ describe('#parseAPIErrorResponse', () => {
|
|||||||
expect(parseAPIErrorResponse('Error: 422 Failed')).toBe(
|
expect(parseAPIErrorResponse('Error: 422 Failed')).toBe(
|
||||||
'提交的信息有误,请检查后重试。'
|
'提交的信息有误,请检查后重试。'
|
||||||
);
|
);
|
||||||
|
expect(parseAPIErrorResponse('timeout of 10000ms exceeded')).toBe(
|
||||||
|
'请求超时,请稍后再试。'
|
||||||
|
);
|
||||||
|
expect(parseAPIErrorResponse('已从会话 ID 14 移除标签 #超时关闭')).toBe(
|
||||||
|
'已从会话 ID 14 移除标签 #超时关闭'
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
parseAPIErrorResponse(new Error('Request failed with status code 401'))
|
parseAPIErrorResponse(new Error('Request failed with status code 401'))
|
||||||
).toBe('身份验证失败,请重新登录。');
|
).toBe('身份验证失败,请重新登录。');
|
||||||
|
|||||||
Reference in New Issue
Block a user