Skip to content

Catch \Throwable in PHP 7 so that fatal errors do not halt test execution (how?) #831

@peterjmit

Description

@peterjmit

I would like to contribute a patch for this, but I have a few questions before I can do that.

Now PHP 7 is out, fatal errors no longer need to halt test execution. It looks like appropriate place in makeCall method in in the CallCenter class

public function makeCall(Call $call)
{
    try {
        $filteredCall = $this->filterCall($call);
        $result = $this->handleCall($filteredCall);
        $filteredResult = $this->filterResult($result);
    } catch (Exception $e) {
        return new CallResult($call, null, $e, null);
    } catch (\Throwable $e) {
        // Cast \Throwable to \Exception?
        $e = throwableToException($e);
        return new CallResult($call, null, $e, null);
    }

    return $filteredResult;
}

I have something along these lines working however I am not sure how to handle the cast of Throwable to Exception in the context of Behat. Symfony handles it via FatalThrowableException but to be frank I don't fully understand the constructor of that class, why is ErrorException instantiated but not assigned for example?

I would appreciate any pointers to getting a PR open (or a PR would be great too)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions