try ... catch applies only to errors that occur when calling this function. Any method that involves downloading files from the network, disk, etc., will be asynchronous, i.e. It does not execute correctly when you call it, but instead, it happens some time after it is called. In this case, you need addEventListener to catch any errors or events or find out when they finished loading.
source
share