I get API 2 deprecation error uhmm advice to change lasterrorcode to ioexception.
The reason I have them around is I would like to prevent Try Catch errors, and the way I do that is lasterrorcode will do a return.
In the LR it doesn’t seem that ioexception will do that.
At the very end of the “copyfileorfolder” example is this line which would be nice if it had a replacement in API 2
If source.LastErrorCode <> 0 Then
Return False
Try
source.CopyTo (destination)
Return True
Catch err as IOException
// Alert user
Return False
End Try
The IOException gives you an error code too. I said “// Alert user” but that’s probably better done by the caller of this method, unless you want to log it right there (actually what I tend to do).
Or you might do both, that is log it to a log file when the error is detected (in the method), and do whatever else is specific to this call, higher up.
Unfortunately, there is no replacement (on MacOS at least). For most things, you can continue to use API 1 for a long time to come. One exception is FolderItem on MacOS, which had to be rewritten due to changes Apple made.