From fea67051d4fe23dfebf543815533b2b1d60a078a Mon Sep 17 00:00:00 2001 From: Oliver Kucharzewski Date: Wed, 28 May 2025 17:26:54 +1000 Subject: [PATCH 1/2] Include createErrorFromThrowable --- docs/reference/public-api.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/reference/public-api.md b/docs/reference/public-api.md index 7a6723784..53acff892 100644 --- a/docs/reference/public-api.md +++ b/docs/reference/public-api.md @@ -47,6 +47,28 @@ try { See [TransactionInterface](#api-transaction-interface) on how to customize a transaction. +### `ElasticApm::createErrorFromThrowable` [api-elasticapm-class-create-error-from-throwable] + +Captures a throwable exception. This API: +* Captures an error as an exception +* Displays it in the ElasticAPM `Errors` screen +* Allows for easy tracking of caught exceptions. + +For example: +```php +use Elastic\Apm\ElasticApm; + +private function captureExceptionFromErrorMessage($message) +{ + try { + throw new Exception($message); + } catch (Throwable $ex) { + ElasticApm::createErrorFromThrowable($ex); + } +} +``` + +The code above would allow for an error message, along with its stack trace to be monitored. ### `ElasticApm::captureCurrentTransaction` [api-elasticapm-class-capture-current-transaction] From 8e485c0e4220c79c9d8202e95a0cb71d2d45e355 Mon Sep 17 00:00:00 2001 From: Oliver Kucharzewski Date: Wed, 28 May 2025 19:39:59 +1000 Subject: [PATCH 2/2] Update public-api.md --- docs/reference/public-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/public-api.md b/docs/reference/public-api.md index 53acff892..e31f582da 100644 --- a/docs/reference/public-api.md +++ b/docs/reference/public-api.md @@ -68,7 +68,7 @@ private function captureExceptionFromErrorMessage($message) } ``` -The code above would allow for an error message, along with its stack trace to be monitored. +The code above would allow for an error message to be tracked via an artificially created exception. ### `ElasticApm::captureCurrentTransaction` [api-elasticapm-class-capture-current-transaction]