Skip to content

Instantly share code, notes, and snippets.

@vladcosorg
Last active August 29, 2015 14:13
Show Gist options
  • Save vladcosorg/3607bceac78ca875341c to your computer and use it in GitHub Desktop.
Save vladcosorg/3607bceac78ca875341c to your computer and use it in GitHub Desktop.
__toString exception workaround
public function __toString() {
try {
return $this->call();
} catch(\Exception $e) {
// the __toString method isn't allowed to throw exceptions
// so we turn them into an error instead
trigger_error($e->getMessage() . "\n" . $e->getTraceAsString(), E_USER_ERROR);
return '';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment