elastic / elastic/apm-agent-php

Expected error being overwritten by last thrown exception

Open
#907 1 comment 0 reactions 0 assignees View on GitHub
agent-php bug priority: medium triaged
Dominant language
PHP
Stars
268
Forks
86
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Occasionally when our application throws an exception, the expected error is replaced by a caught exception that is thrown in the error handler.

A basic example of what I'm seeing is that our application will throw

```
throw new Exception('Cancellation failed. '.$e->getMessage());
```

which Laravel reports to Sentry. Sentry has the correct error but this is the exception reported to ELK:

![image](https://user-images.githubusercontent.com/1852424/228913659-e6012ad5-3e07-4d7a-acbf-ffb843c23750.png)

However, this exception is caught and ignored in `getComposerPackages`.

![image](https://user-images.githubusercontent.com/1852424/228914049-166ead61-ccd7-4438-af66-d19ba9729757.png)

**To Reproduce**
I've been unable to replicate this outside of our environment. I will create an application with our exact versions and try to replicate it.

**Expected behavior**
The correct exception is reported.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.