consistently use finally {} for cleanup in html/js

This commit is contained in:
Mechiel Lukkien 2023-02-06 15:23:33 +01:00
parent 6cbe4d5d37
commit 37713a974c
No known key found for this signature in database
2 changed files with 20 additions and 19 deletions

View file

@ -161,7 +161,7 @@ const index = async () => {
window.alert('Password has been changed.') window.alert('Password has been changed.')
form.reset() form.reset()
} catch (err) { } catch (err) {
console.log('error', err) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
} finally { } finally {
fieldset.disabled = false fieldset.disabled = false
@ -193,7 +193,7 @@ const init = async () => {
dom._kids(page, 'page not found') dom._kids(page, 'page not found')
} }
} catch (err) { } catch (err) {
console.log('error', err) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
window.location.hash = curhash window.location.hash = curhash
curhash = window.location.hash curhash = window.location.hash

View file

@ -216,10 +216,10 @@ const index = async () => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
fieldset.disabled = false
return return
} } finally {
fieldset.disabled = false fieldset.disabled = false
}
window.location.hash = '#domains/' + domain.value window.location.hash = '#domains/' + domain.value
}, },
fieldset=dom.fieldset( fieldset=dom.fieldset(
@ -433,10 +433,10 @@ const accounts = async () => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
fieldset.disabled = false
return return
} } finally {
fieldset.disabled = false fieldset.disabled = false
}
window.location.hash = '#accounts/'+account.value window.location.hash = '#accounts/'+account.value
}, },
fieldset=dom.fieldset( fieldset=dom.fieldset(
@ -515,10 +515,10 @@ const account = async (name) => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
e.target.disabled = false
return return
} } finally {
e.target.disabled = false e.target.disabled = false
}
window.location.reload() // todo: reload just the list window.location.reload() // todo: reload just the list
}), }),
), ),
@ -545,10 +545,10 @@ const account = async (name) => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
fieldset.disabled = false
return return
} } finally {
fieldset.disabled = false fieldset.disabled = false
}
form.reset() form.reset()
window.location.reload() // todo: only reload the destinations window.location.reload() // todo: only reload the destinations
}, },
@ -585,8 +585,9 @@ const account = async (name) => {
window.alert('Password has been changed.') window.alert('Password has been changed.')
formPassword.reset() formPassword.reset()
} catch (err) { } catch (err) {
console.log('error', err) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
return
} finally { } finally {
fieldsetPassword.disabled = false fieldsetPassword.disabled = false
} }
@ -605,10 +606,10 @@ const account = async (name) => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
e.target.disabled = false
return return
} } finally {
e.target.disabled = false e.target.disabled = false
}
window.location.hash = '#accounts' window.location.hash = '#accounts'
}), }),
) )
@ -689,10 +690,10 @@ const domain = async (d) => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
e.target.disabled = false
return return
} } finally {
e.target.disabled = false e.target.disabled = false
}
window.location.reload() // todo: only reload the localparts window.location.reload() // todo: only reload the localparts
}), }),
), ),
@ -712,10 +713,10 @@ const domain = async (d) => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
fieldset.disabled = false
return return
} } finally {
fieldset.disabled = false fieldset.disabled = false
}
form.reset() form.reset()
window.location.reload() // todo: only reload the addresses window.location.reload() // todo: only reload the addresses
}, },
@ -755,10 +756,10 @@ const domain = async (d) => {
} catch (err) { } catch (err) {
console.log({err}) console.log({err})
window.alert('Error: ' + err.message) window.alert('Error: ' + err.message)
e.target.disabled = false
return return
} } finally {
e.target.disabled = false e.target.disabled = false
}
window.location.hash = '#' window.location.hash = '#'
}), }),
) )