class MyCustomException extends Exception { public function __toString() { return "MyCustomException: " . $this->message; } }
try { // some code that may throw MyCustomException } catch (MyCustomException $ex) { echo $ex; // will output "MyCustomException: error message" }This code example may be part of a package or library for handling exceptions in a more customizable and user-friendly way.