8000 View exception handling fix (discussion) by kirkbushell · Pull Request #7965 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

View exception handling fix (discussion) #7965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
22 changes: 13 additions & 9 deletions src/Illuminate/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,18 @@ public function __call($method, $parameters)
throw new BadMethodCallException("Method [$method] does not exist on view.");
}

/**
* Get the string contents of the view.
*
* @return string
*/
public function __toString()
{
return $this->render();
}
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent with tabs.

* Get the string contents of the view.
*
* @return string
*/
public function __toString()
{
try {
return $this->render();
} catch (\Exception $e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please import this.

return $e->getMessage();
}
}

}
8 changes: 8 additions & 0 deletions tests/View/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ public function testWithErrors()
}


public function testViewExceptionHandling()
Copy link
Member
9822

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent with tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No offense - but will worry about that once I know what sort of solution I should be going with :)

{
$view = $this->getView();

$this->assertEquals('Method Mockery_0_Illuminate_View_Factory::incrementRender() does not exist on this mock object', (string) $view);
}


protected function getView()
{
return new View(
Expand Down
0