Demonstrates the FileException scenarios thrown by the library.
Six error conditions, each caught with try/catch:
- File not found —
read()on a path that doesn't exist - Empty file name —
read()with no name set - Empty path —
read()with a name but no directory (and file not in calling script's directory) - No data to write —
write()without callingsetRawData()first - Read past end of file —
read($from, $to)where$toexceeds the file size - Invalid Base64 —
setRawData($data, true, true)with strict mode on invalid input
WebFiori\File\Exceptions\FileException— Extends PHP'sException. Thrown byFileandFileUploadermethods on error.
php examples/error-handling.php