Skip to content

Commit e66bcc5

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 5c13ece commit e66bcc5

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

ui/src/utils/plugins.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,19 @@ export const notifierPlugin = {
294294
if (error.response.status) {
295295
msg = `${i18n.global.t('message.request.failed')} (${error.response.status})`
296296
}
297-
if (error.message) {
298-
desc = error.message
299-
}
300-
if (error.response.headers && 'x-description' in error.response.headers) {
297+
if (error.response.headers?.['x-description']) {
301298
desc = error.response.headers['x-description']
302-
}
303-
if (desc === '' && error.response.data) {
299+
} else if (error.response.data) {
304300
const responseKey = _.findKey(error.response.data, 'errortext')
305301
if (responseKey) {
306302
desc = error.response.data[responseKey].errortext
303+
} else if (typeof error.response.data === 'string') {
304+
desc = error.response.data
307305
}
308306
}
307+
if (!desc && error.message) {
308+
desc = error.message
309+
}
309310
}
310311
let countNotify = store.getters.countNotify
311312
countNotify++

ui/src/views/image/RegisterOrUploadTemplate.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,7 @@ export default {
684684
this.$emit('refresh-data')
685685
this.closeAction()
686686
}).catch(e => {
687-
this.$notification.error({
688-
message: this.$t('message.upload.failed'),
689-
description: `${this.$t('message.upload.template.failed.description')} - ${e}`,
690-
duration: 0
691-
})
687+
this.$notifyError(e)
692688
})
693689
},
694690
fetchCustomHypervisorName () {

0 commit comments

Comments
 (0)