Message
API reference › HTML SVG › Exception › Message
Represents error message templates.
This enum defines formatted error messages for various error conditions that may occur during operations such as value validation.
It provides message templates that can be formatted at call sites.
Each case represents a specific type of error, with a message template that can be populated with dynamic values
using the Message::getMessage() method.
Each message template can be formatted with arguments.
| Case | Value | Description |
|---|---|---|
CONTENT_AND_FILEPATH_CANNOT_BE_BOTH_EMPTY | 'File path and content cannot be empty at the same time for SVG.' | Error when both content and file path are empty. |
FAILED_TO_READ_FILE | "Failed to read file: '%s'." | Error when failed to read a file. |
FAILED_TO_SANITIZE_SVG | "Failed to sanitize SVG content from file: '%s'." | Error when failed to sanitize SVG content from a file. |
ICON_REFERENCE_FILE_NOT_FOUND | "Icon reference '%s' does not resolve to a bundled SVG file." | Error when the icon reference resolves to a path that is not a bundled SVG file. |
ICON_REFERENCE_MUST_BE_COLLECTION_NAME | "Icon reference '%s' must be in the form 'Collection:name'." | Error when the icon reference does not follow the Collection:name format. |
TITLE_ATTRIBUTE_MUST_BE_STRING_OR_NULL | "Title attribute must be a 'string' or 'null'." | Error when the title attribute is not a string or null. |
VALUE_MUST_BE_GTE_ONE_OR_NULL | "Value must be a number greater than or equal to '1' or 'null' to unset." | Error when the value is not a number >= 1 or null. |
VALUE_MUST_BE_POSITIVE_NUMBER_OR_NULL | "Value must be a positive number or 'null' to unset." | Error when the value is not a positive number or null. |
VALUE_OUT_OF_RANGE_OR_NULL | "Value must be a number between '%s' and '%s' inclusive or 'null' to unset." | Error when the value is out of range or not null. |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
getMessage() | Returns the formatted message string for the error case. | Message |
Method details
Section titled “Method details”getMessage()
Section titled “getMessage() ”public function getMessage(int|string ...$argument): stringReturns the formatted message string for the error case.
Parameters
| Parameter | Type | Description |
|---|---|---|
...$argument | int| | Values to insert into the message template. |
Returns
string: Formatted error message with interpolated arguments. Usage example: throw new InvalidArgumentException(Message::FAILED_TO_READ_FILE->getMessage($filePath));