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().
use WeasyPrint\Exceptions\InvalidConfigValueException;This is thrown for:
dpiset to 0 or a negative numberjpegQualityoutside the 0-95 rangeinputEncodingnot supported bymb_list_encodings()
Source Errors
SourceNotSetException
Thrown when calling build() or addAttachment() without first preparing a source.
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.
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.
use WeasyPrint\Exceptions\UnsupportedVersionException;AttachmentNotFoundException
Thrown during a build if an attachment file path does not exist on disk.
use WeasyPrint\Exceptions\AttachmentNotFoundException;TemporaryFileException
Thrown when the package fails to write the HTML source to a temporary file for processing.
use WeasyPrint\Exceptions\TemporaryFileException;Output Errors
MissingOutputFileException
Thrown when the WeasyPrint binary completes but no output file is found at the expected path.
use WeasyPrint\Exceptions\MissingOutputFileException;OutputReadFailedException
Thrown when the output file exists but cannot be read into memory.
use WeasyPrint\Exceptions\OutputReadFailedException;