Skip to content

Catch Throwable instead of Exception in CallCenter#667

Open
ranpafin wants to merge 1 commit into
phpspec:masterfrom
ranpafin:fix/record-throwable-calls-595
Open

Catch Throwable instead of Exception in CallCenter#667
ranpafin wants to merge 1 commit into
phpspec:masterfrom
ranpafin:fix/record-throwable-calls-595

Conversation

@ranpafin
Copy link
Copy Markdown
Contributor

When a promise throws a Throwable that is not an Exception (e.g. TypeError),
CallCenter does not catch it, so the call is never recorded.

This changes the catch block in CallCenter and the type hint in Call from
Exception to Throwable, aligning them with ThrowPromise which already
accepts Throwable.

Closes #595

…wn errors

When a promise throws a Throwable that is not an Exception (e.g. TypeError,
Error), the CallCenter catch block missed it, so the call was never recorded.
This aligns CallCenter and Call with ThrowPromise which already supports
Throwable.

Fixes phpspec#595
@Nek-
Copy link
Copy Markdown
Contributor

Nek- commented Mar 21, 2026

Prophecy is a highly opiniated framework. I think not catching throwable is part of it since you should never throw PHP errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When a mocked method throws a Throwable the call to the method is not recorded

2 participants