-
Notifications
You must be signed in to change notification settings - Fork 0
Usage: Message Errors
For error handling, peekaboo uses an enum of Error conditions, provided by at\peekaboo\MessageError.
These error cases are thrown as MessageExceptions.
You can refer to the at\exceptable package to understand more about how this works.*
* Peekaboo will use the Exceptable library if it is installed, but does not directly depend on it in order to avoid circular dependencies. If it is not installed, peekaboo defines stub implementations.
This means you can catch MessageExceptions, and compare them to the MessageError case(s) you're interested in:
use at\peekaboo\ {
MessageError,
MessageException
};
try {
$message = $hasMessages->makeMessage($key, $context);
} catch (MessageException $e) {
if ($e->is(MessageError::FormatFailed)) {
// log it, maybe provide a default message, etc.
} else {
throw $e;
}
}-
This error is thrown when formatting a message fails. It provides you with debugging info, including the locale, format string, context, and the error code and message from the
intlextension (if one exists).error formatting message: (31) U_INPUT_TOO_LONG_ERROR locale: en_US format: darkness is upon me, and {tm} night must fall context: {"tm":"soon"} -
This error is thrown when looking up a format by key, but the value found is not a message format (e.g., looking up
foo.barbutbaris actually another message bundle).value at YourClass:foo.bar is not a message format string -
This error is thrown when trying to look up a message format on a peekaboo class's
MESSAGESconst, but the value you declared is malformed or not an array. (This is a bug for you to fix ;)MakesMessages::MESSAGES must be an array of message formats; string declared