Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
suppressed-exceptions
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
grifart libs
suppressed-exceptions
Commits
e3b0182b
Commit
e3b0182b
authored
6 years ago
by
Jan Kuchař
Browse files
Options
Downloads
Patches
Plain Diff
Update README.md
parent
0afaad19
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#13411
passed
6 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+38
-5
38 additions, 5 deletions
README.md
with
38 additions
and
5 deletions
README.md
+
38
−
5
View file @
e3b0182b
...
...
@@ -2,9 +2,11 @@
repositories:
[
Grifart GitLab
](
https://gitlab.grifart.cz/grifart/suppressed-exceptions
)
,
[
GitHub
](
https://github.com/grifart/suppressed-exceptions
)
Suppressed exceptions are useful for aggregating more exceptions
with
unreliable resources.
Suppressed exceptions are useful for aggregating more exceptions
from
unreliable resources.
You want to communicate that process failed, with following list of sibling exceptions that led to this error.
Useful when you want to communicate that process failed, with a list of sibling exceptions that led to an error.
## Example usage
```
php
$remoteSources
=
[];
// classes representing unreliable remote sources
...
...
@@ -12,17 +14,48 @@ $remoteSources = []; // classes representing unreliable remote sources
$exceptions
=
[];
foreach
(
$remoteSoures
as
$remoteSource
)
{
try
{
$remoteSource
->
fetch
();
// un
realiable
$remoteSource
->
fetch
();
// un
safe operation
}
catch
(
FetchingFailed
$e
)
{
$exceptions
[]
=
$e
;
continue
;
}
}
if
(
count
(
$exceptions
)
>
0
)
{
if
(
count
(
$exceptions
)
>
0
)
{
$e
=
new
ProcessingFailed
();
$e
->
addSuppressed
(
...
$exceptions
);
throw
$e
;
}
```
You can also override exception constructor to provide better API
```
php
final
class
EventPropagationFailedException
extends
\RuntimeException
implements
\Grifart\SuppressedExceptions\WithSuppressedExceptions
{
use
\Grifart\SuppressedExceptions\SuppressedExceptions
;
public
function
__construct
(
\Throwable
...
$suppressed
)
{
parent
::
__construct
(
'Saving succeeded, but some listeners failed to complete their job. Please check suppressed exceptions for more information.'
);
$this
->
addSuppressed
(
...
$suppressed
);
}
}
```
Usage is then
```
php
throw
new
EventPropagationFailedException
(
...
$suppressedExceptions
);
```
**TODO: screenshot from debugger**
how it looks when catched
## More reading
-
https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html#suppressed-exceptions
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment