feat: toast the http request error (#5796)

#### What type of PR is this?

/area ui
/kind improvement
/milestone 2.15.x

#### What this PR does / why we need it:

优化 Console 的请求异常提示,如果异常不满足原有的判断逻辑,最终将提示 status + statusText,不再显示未知错误,方便使用者根据异常提示进行排查。

<img width="246" alt="image" src="https://github.com/halo-dev/halo/assets/21301288/86111068-69a1-4ac1-b405-eea69a95e141">

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/5739

#### Special notes for your reviewer:

我的测试方式:

使用 Caddy 模拟请求异常:

```
:9000

encode gzip

@blocked {
   path /apis/content.halo.run/v1alpha1/posts/**
}

respond @blocked 413

reverse_proxy 127.0.0.1:8090
```

#### Does this PR introduce a user-facing change?

```release-note
优化 Console 的请求异常提示,方便异常排查。
```
pull/5787/head
Ryan Wang 2024-04-25 16:13:12 +08:00 committed by GitHub
parent 9054e1fb92
commit 924aad1304
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -116,6 +116,13 @@ axiosInstance.interceptors.response.use(
return Promise.reject(error);
}
// Final fallback
if (errorResponse.status) {
const { status, statusText } = errorResponse;
Toast.error([status, statusText].filter(Boolean).join(": "));
return Promise.reject(error);
}
Toast.error(i18n.global.t("core.common.toast.unknown_error"));
return Promise.reject(error);