added feedback from @nunomaduro

This commit is contained in:
Adrian Nürnberger
2020-06-19 20:39:09 +02:00
parent d0a74931dd
commit 75f7ee0acf
6 changed files with 23 additions and 73 deletions

View File

@ -18,10 +18,10 @@ final class ExceptionTrace
* Ensures the given closure reports
* the good execution context.
*/
public static function ensure(Closure $closure): Mixed
public static function ensure(Closure $closure)
{
try {
return new Mixed($closure());
return $closure();
} catch (Throwable $throwable) {
if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_METHOD)) {
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);