Skip to content

Commit

Permalink
[ErrorHandler] Improve an error message
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 3, 2025
1 parent 3590ca3 commit 126f556
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function enhance(\Throwable $error): ?\Throwable
if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
$functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
$namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
$message = \sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
$message = \sprintf('Attempted to call undefined function "%s" from namespace "%s".', $functionName, $namespacePrefix);
} else {
$functionName = $fullyQualifiedFunctionName;
$message = \sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
$message = \sprintf('Attempted to call undefined function "%s" from the global namespace.', $functionName);
}

$candidates = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ public static function provideUndefinedFunctionData()
return [
[
'Call to undefined function test_namespaced_function()',
"Attempted to call function \"test_namespaced_function\" from the global namespace.\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?",
"Attempted to call undefined function \"test_namespaced_function\" from the global namespace.\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?",
],
[
'Call to undefined function Foo\\Bar\\Baz\\test_namespaced_function()',
"Attempted to call function \"test_namespaced_function\" from namespace \"Foo\\Bar\\Baz\".\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?",
"Attempted to call undefined function \"test_namespaced_function\" from namespace \"Foo\\Bar\\Baz\".\nDid you mean to call \"\\symfony\\component\\errorhandler\\tests\\errorenhancer\\test_namespaced_function\"?",
],
[
'Call to undefined function foo()',
'Attempted to call function "foo" from the global namespace.',
'Attempted to call undefined function "foo" from the global namespace.',
],
[
'Call to undefined function Foo\\Bar\\Baz\\foo()',
'Attempted to call function "foo" from namespace "Foo\Bar\Baz".',
'Attempted to call undefined function "foo" from namespace "Foo\Bar\Baz".',
],
];
}
Expand Down

0 comments on commit 126f556

Please sign in to comment.