serp-spider / core

:spider: The PHP SERP Spider - A search engine scraper
https://serp-spider.github.io/
Other
89 stars 44 forks source link

Add a parser error manager #7

Open gsouf opened 8 years ago

gsouf commented 8 years ago

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: