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

Skip to content
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
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
Collaborator

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
Collaborator

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
Collaborator

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