Skip to content

Error Handling

The package throws specific exceptions for different failure scenarios. All exceptions extend RuntimeException.

Configuration Errors

InvalidConfigValueException

Thrown when a config value fails validation during construction or after calling tapConfig() / setConfig().

php
use WeasyPrint\Exceptions\InvalidConfigValueException;

This is thrown for:

  • dpi set to 0 or a negative number
  • jpegQuality outside the 0-95 range
  • inputEncoding not supported by mb_list_encodings()

Source Errors

SourceNotSetException

Thrown when calling build() or addAttachment() without first preparing a source.

php
use WeasyPrint\Exceptions\SourceNotSetException;

Build Errors

BinaryNotFoundException

Thrown when the WeasyPrint binary cannot be found or is not executable. This applies both when a custom path is configured via the binary config option and when the package attempts to locate it automatically.

php
use WeasyPrint\Exceptions\BinaryNotFoundException;

UnsupportedVersionException

Thrown at the start of a build if the installed WeasyPrint binary version does not satisfy the package's version constraint.

php
use WeasyPrint\Exceptions\UnsupportedVersionException;

AttachmentNotFoundException

Thrown during a build if an attachment file path does not exist on disk.

php
use WeasyPrint\Exceptions\AttachmentNotFoundException;

TemporaryFileException

Thrown when the package fails to write the HTML source to a temporary file for processing.

php
use WeasyPrint\Exceptions\TemporaryFileException;

Output Errors

MissingOutputFileException

Thrown when the WeasyPrint binary completes but no output file is found at the expected path.

php
use WeasyPrint\Exceptions\MissingOutputFileException;

OutputReadFailedException

Thrown when the output file exists but cannot be read into memory.

php
use WeasyPrint\Exceptions\OutputReadFailedException;

Released under the ISC License.