diff --git a/CHANGELOG.md b/CHANGELOG.md index 40ef00d88f..5452abe40d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ These are the section headers that we use: ## [Unreleased]() +### Added + +- Added strategy to handle and translate errors from server for `401 http status code` ([#4362](https://github.com/argilla-io/argilla/pull/4362)) + ## [1.20.0](https://github.com/argilla-io/argilla/compare/v1.19.0...v1.20.0) ### Added diff --git a/frontend/plugins/plugins/axios.ts b/frontend/plugins/plugins/axios.ts index 14c97fff62..47de1d1cf4 100644 --- a/frontend/plugins/plugins/axios.ts +++ b/frontend/plugins/plugins/axios.ts @@ -49,6 +49,8 @@ export default ({ $axios, app }) => { params: {}, }; + Notification.dispatch("clear"); + switch (code) { case 400: Notification.dispatch("notify", { @@ -81,11 +83,19 @@ export default ({ $axios, app }) => { type: "warning", }); break; - default: + case 401: { + Notification.dispatch("notify", { + message: app.i18n.t(detail.code), + type: "error", + }); + break; + } + default: { Notification.dispatch("notify", { message: `Error: ${detail.params.details ?? detail.params.message}`, type: "error", }); + } } throw error; diff --git a/frontend/translation/en.json b/frontend/translation/en.json index 5e6b580e94..8d8470a247 100644 --- a/frontend/translation/en.json +++ b/frontend/translation/en.json @@ -54,5 +54,10 @@ "reset": "Reset", "with": "with", "find": "Find", - "cancel": "Cancel" -} \ No newline at end of file + "cancel": "Cancel", + "argilla": { + "api": { + "errors::UnauthorizedError": "Could not validate credentials" + } + } +}