Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 828 Bytes

File metadata and controls

24 lines (16 loc) · 828 Bytes

Error Handling

Demonstrates the FileException scenarios thrown by the library.

What It Covers

Six error conditions, each caught with try/catch:

  1. File not foundread() on a path that doesn't exist
  2. Empty file nameread() with no name set
  3. Empty pathread() with a name but no directory (and file not in calling script's directory)
  4. No data to writewrite() without calling setRawData() first
  5. Read past end of fileread($from, $to) where $to exceeds the file size
  6. Invalid Base64setRawData($data, true, true) with strict mode on invalid input

Key Class

  • WebFiori\File\Exceptions\FileException — Extends PHP's Exception. Thrown by File and FileUploader methods on error.

Run

php examples/error-handling.php