Skip to content

Commit b7a6023

Browse files
Damans227Daman Arora
authored andcommitted
improve error handling for template upload notifications (apache#12412)
Co-authored-by: Daman Arora <daman.arora@shapeblue.com>
1 parent b443402 commit b7a6023

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

ui/src/utils/plugins.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,19 @@ export const notifierPlugin = {
224224
if (error.response.status) {
225225
msg = `${i18n.global.t('message.request.failed')} (${error.response.status})`
226226
}
227-
if (error.message) {
228-
desc = error.message
229-
}
230-
if (error.response.headers && 'x-description' in error.response.headers) {
227+
if (error.response.headers?.['x-description']) {
231228
desc = error.response.headers['x-description']
232-
}
233-
if (desc === '' && error.response.data) {
229+
} else if (error.response.data) {
234230
const responseKey = _.findKey(error.response.data, 'errortext')
235231
if (responseKey) {
236232
desc = error.response.data[responseKey].errortext
233+
} else if (typeof error.response.data === 'string') {
234+
desc = error.response.data
237235
}
238236
}
237+
if (!desc && error.message) {
238+
desc = error.message
239+
}
239240
}
240241
let countNotify = store.getters.countNotify
241242
countNotify++

ui/src/views/image/RegisterOrUploadTemplate.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,7 @@ export default {
677677
this.$emit('refresh-data')
678678
this.closeAction()
679679
}).catch(e => {
680-
this.$notification.error({
681-
message: this.$t('message.upload.failed'),
682-
description: `${this.$t('message.upload.template.failed.description')} - ${e}`,
683-
duration: 0
684-
})
680+
this.$notifyError(e)
685681
})
686682
},
687683
fetchCustomHypervisorName () {

0 commit comments

Comments
 (0)