From 18191294235a832698769d8c785d2c90cae4e5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kucha=C5=99?= <honza.kuchar@grifart.cz> Date: Tue, 6 Nov 2018 13:34:32 +0100 Subject: [PATCH] added basic readme --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..481da3a --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# Suppressed exceptions for PHP + +Suppressed exceptions are useful for aggregating more exceptions with unreliable resources. + +You want to communicate that process failed, with following list of sibling exceptions that led to this error. + +```php +$remoteSources = []; // classes representing unreliable remote sources + +$exceptions = []; +foreach ($remoteSoures as $remoteSource) { + try { + $remoteSource->fetch(); // unrealiable + } catch (FetchingFailed $e) { + $exceptions[] = $e; + continue; + } +} + +if (count($exceptions) > 0) { + $e = new ProcessingFailed(); + $e->addSuppressed(...$exceptions); + throw $e; +} + +``` \ No newline at end of file -- GitLab