For context, I am trying to do a save system for a game.
I would use both.
I would explicitly check in this case - but this might not be the right way if you were doing something else, like updating a row in a table millions of times a second. It’s always context dependent.
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.
If you’re already using an existing engine this is already baked in.
But a new engine I would suggest confirming that the file is there and that there is no handles holding it.
I saw long time ago from somewhere saying that handling exception is expensive in terms of stack operations. To avoid the unexpected I guess you should do both, but a check before loading just saves you from unnecessary exception handlings which, if the very first statement is indeed true, would harm the performance.
It is an expensive operation as it needs to unwind the stack to get the stack trace.
But if you’re checking a single file you won’t notice it.
If you’re doing it in a tight loop it’ll be very noticeable.
Checking the file exists also has a cost.
I likely wouldn’t bother if I was saving a single file especially as there are other exceptions that could be thrown in the process.