Skip to content

Commit 1d6778b

Browse files
authored
Ensure endpoint is deleted before creating a new one in "Delete and Add" (#1661)
1 parent 118bf2e commit 1d6778b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/components/ZclCreateModifyEndpoint.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,16 @@ export default {
664664
deleteAndAddDeviceType() {
665665
this.showDeviceTypeChangeDialog = false
666666
this.deleteEpt(this.endpointReference)
667-
this.newEpt()
667+
.then(() => {
668+
this.newEpt()
669+
})
670+
.catch((err) => {
671+
console.error('Error in deleteAndAddDeviceType:', err)
672+
})
668673
},
669674
deleteEpt(endpointReference) {
670675
// Logic to delete the existing endpoint
671-
this.$store
676+
return this.$store
672677
.dispatch('zap/deleteEndpoint', endpointReference)
673678
.then(() => {
674679
return this.$store.dispatch(
@@ -677,9 +682,8 @@ export default {
677682
)
678683
})
679684
.catch((err) => {
680-
console.error(
681-
`Error deleting endpoint ${endpointReference}: ${err.message}`
682-
)
685+
const errorMsg = `Error deleting endpoint ${endpointReference}: ${err.message || err}`
686+
throw new Error(errorMsg) // Throw formatted error
683687
})
684688
},
685689
reqValue(value) {

0 commit comments

Comments
 (0)