Nextar
Nextar

Reputation: 1098

PHP exception overwirte toString()

I'm having problems with my own exception class: IOExeption. I want it to have another output then the normal exception class but in spite of the code below, its output is still the same.
What am I doing wrong ?

class IOExeption extends Exception
{
    public function __toString()
    {
        $string  = '<h1 class="text-warning text-center">';
        $string .= $this->getMessage();
        $string .= '</h1>';
        return $string;
    }
}

Upvotes: 0

Views: 861

Answers (1)

Your Common Sense
Your Common Sense

Reputation: 157897

As a matter of fact, exceptions should have no output at all.

Whatever output have to be done in the exception handler only. And only in case it is development server which the only user you are. Otherwise it have to log the error message in plain text.

Upvotes: 2

Related Questions