Binette to Learn [email protected]English • 2 months agoIs it better to check if a file exists before trying to load it, or to try to load it, and catch the error and move on?message-square16fedilinkarrow-up137arrow-down10file-text
arrow-up137arrow-down1message-squareIs it better to check if a file exists before trying to load it, or to try to load it, and catch the error and move on?Binette to Learn [email protected]English • 2 months agomessage-square16fedilinkfile-text
minus-square@[email protected]linkfedilink5•2 months agoYou should do both. Creation and catching of exceptions can be an expensive process and even if the check for the file succeeds the loading of the file may not in which case you’ll need to handle the exceptions anyway.
You should do both. Creation and catching of exceptions can be an expensive process and even if the check for the file succeeds the loading of the file may not in which case you’ll need to handle the exceptions anyway.