NormalizedException
A helper for making exceptions play nice with PSR-3 logging
Loading...
Searching...
No Matches
Wikimedia\NormalizedException\INormalizedException Interface Reference

Interface for exceptions whose error message supports PSR-3 style placeholders. More...

+ Inheritance diagram for Wikimedia\NormalizedException\INormalizedException:

Public Member Functions

 getNormalizedMessage ()
 Returns a normalized version of the error message, with PSR-3 style placeholders.
 
 getMessageContext ()
 Returns the context data.
 

Detailed Description

Interface for exceptions whose error message supports PSR-3 style placeholders.

This allows extracting variable parts of the error message, so that the remaining normalized message can be used for better grouping of related errors in the logs.

E.g. an exception message ‘User 'Foo’ not foundcould be normalized into User '{user}' not found, with[ 'user' => 'Foo' ]` as context data.

@stable to implement

Member Function Documentation

◆ getMessageContext()

Wikimedia\NormalizedException\INormalizedException::getMessageContext ( )

Returns the context data.

All placeholders in the normalized message must have a matching field in the array. Extra fields are allowed. Keys should match /[a-zA-Z0-9_.]+/, as per the PSR-3 spec. Values should be scalars.

Returns
(int|float|string|bool)[]

◆ getNormalizedMessage()

Wikimedia\NormalizedException\INormalizedException::getNormalizedMessage ( )

Returns a normalized version of the error message, with PSR-3 style placeholders.

After replacing the placeholders with their values from the context data, the result should be equal to getMessage().

Returns
string

The documentation for this interface was generated from the following file: