2 ms·
Try without a catch is fairly common and IMO quite fine when it's not the current method's job to deal with an error but it is its job to clean up state or some
by vimslayer 7y ago
Try without a catch is fairly common and IMO quite fine when it's not the current method's job to deal with an error but it is its job to clean up state or some resources.
async showImage() {
this.showLoadingSpinner = true
try {
this.imageData = await fetchImageData()
} finally {
this.showLoadingSpinner = false
}
}
There might be a parent class/component/whatever that deals with errors and shows them to the user. The image component is responsible for showing the loading spinner and it shouldn't be left spinning if there's an error.