Breaking: #105920 - Folder->getSubFolder() throws FolderDoesNotExistException

See forge#105920

Description

An exception handling detail within FAL/Resource handling has been changed: When calling getSubFolder('mySubFolderName') on a \TYPO3\CMS\Core\Resource\Folder object, and if this sub folder does not exist, the specific \TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException is now raised instead of the global \InvalidArgumentException.

Impact

The change may have impact on extensions that directly or indirectly call Folder->getSubFolder() and expect a \InvalidArgumentException to be thrown.

Affected installations

FolderDoesNotExistException does not extend \InvalidArgumentException. Code that currently expects a \InvalidArgumentException to be thrown, needs adaption.

Migration

The change is breaking for code that takes an "optimistic" approach like "get the sub folder object, and if this throws, create one". Example:

try {
    $mySubFolder = $myFolder->getSubFolder('mySubFolder');
} catch (\InvalidArgumentException) {
    $mySubFolder = $myFolder->createFolder('mySubFolder');
}
Copied!

This should be changed to catch a FolderDoesNotExistException instead:

Extensions that need to stay compatible with both TYPO3 v13 and v14 should catch both exceptions and should later avoid catching \InvalidArgumentException when v13 compatibility is dropped: