An error manager should be available for parser. The reason is that the way errors are managed depend on the user of the library.
Sometimes people want the script execution fails, sometimes people want just the value to be null, and that will still depend on what kind of error.
The idea would be to use an error manager that can recognize error type and act according to the detected error.
Example with google client:
we want to throw exceptions when error happens while parsing a classical result, but not for other result type
but we want to return null when google failed to parse the title
Additionally everything will go in an error bag, containing the name/attributes of the error, the description of the error, a trace of the error (like exceptions), and the resolution chosen.
This is very repository specific, then it will be implemented as a component, and it will be added as a dependency on the packages that need it, and for instance we can define it globally for google GoogleClient::registerParsingErrorHandler($errorHandler) or per google client $googleClient->setErrorHandler($errorHandler); then other packages can do the same.
The way errors will be detected is still obscure, the obvious options would be:
redis-like keys NAMESPACE::ITEM::DETAILS e.g: GOOGLE::PARSING::CLASSICAL::TITLE
and match it with regexp e.g : GOOGLE::PARSING::*
An error manager should be available for parser. The reason is that the way errors are managed depend on the user of the library.
Sometimes people want the script execution fails, sometimes people want just the value to be null, and that will still depend on what kind of error.
The idea would be to use an error manager that can recognize error type and act according to the detected error.
Example with google client:
Additionally everything will go in an error bag, containing the name/attributes of the error, the description of the error, a trace of the error (like exceptions), and the resolution chosen.
This is very repository specific, then it will be implemented as a component, and it will be added as a dependency on the packages that need it, and for instance we can define it globally for google
GoogleClient::registerParsingErrorHandler($errorHandler)
or per google client$googleClient->setErrorHandler($errorHandler);
then other packages can do the same.The way errors will be detected is still obscure, the obvious options would be:
NAMESPACE::ITEM::DETAILS
e.g:GOOGLE::PARSING::CLASSICAL::TITLE
and match it with regexp e.g :GOOGLE::PARSING::*