Skip to content

Commit 26633ba

Browse files
ACPT-1587
For exceptions of type GraphQL\Error\Error, use previous exception if available. Otherwise, the stack trace that shows up in New Relic is not that useful because New Relic doesn't show the previous exception's stack trace.
1 parent 830ed34 commit 26633ba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/code/Magento/GraphQlNewRelic/Plugin/ReportError.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public function __construct(private NewRelicWrapper $newRelicWrapper)
3535
public function beforeHandle(ErrorHandler $subject, array $errors, callable $formatter)
3636
{
3737
if (!empty($errors)) {
38-
$this->newRelicWrapper->reportError($errors[0]); // Note: We only log the first error because performance
38+
$error = $errors[0];
39+
if (($error instanceof Error ) && $error->getPrevious()) {
40+
$error = $error->getPrevious();
41+
}
42+
$this->newRelicWrapper->reportError($error); // Note: We only log the first error because performance
3943
}
4044
return null;
4145
}

0 commit comments

Comments
 (0)