Skip to content

Commit c911a07

Browse files
authored
test(assertions): Add origin of error in QueryResultAssertionTrait output (drupal-graphql#1162)
1 parent f9c573a commit c911a07

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tests/src/Traits/QueryResultAssertionTrait.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ private function assertResultErrors(ExecutionResult $result, array $expected): v
165165
}
166166

167167
if (!$match) {
168-
$unexpected[] = $error_message;
168+
// Add error location information of the original error in the chain to
169+
// show developers where to look.
170+
$original_error = $error;
171+
while ($original_error->getPrevious() !== NULL) {
172+
$original_error = $original_error->getPrevious();
173+
}
174+
$unexpected[] = "Error message: ${error_message}\n Originated in: {$original_error->getFile()}:{$original_error->getLine()}";
169175
}
170176
}
171177

0 commit comments

Comments
 (0)