Extending Exception to contain method name


Posted on 16th Feb 2014 07:03 pm by admin

I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a method where it has been thrown.
Right now I have this:


class myException extends Exception {

protected $method;

public function __construct($message, $method, $code = 0, Exception $previous = null) {
$this->method = $method;
parent::__construct($message, $code, $previous);
}

public function getMethod() {
return $this->method;
}
}

but passing __METHOD__ as a parameter whenever exception is thrown doesn't look really good...

[edit]

Oh wait a second... I can get it from trace, can't I?

No comments posted yet

Your Answer:

Login to answer
94 Like 49 Dislike
Previous forums Next forums
Other forums

Please help with code for SMTP authenticated PHP email form
Hello, I'm creating a PHP email form, and for this particular server, I have to use SMTP Authenticat

dynamic table with forms
I have a table that is populated with mysql data and in teh first column there is a raido button tha

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

Include with Parameters
In a particular page I would like to include a file that requires $_GET parameters.

when I go

How to ... (FAQs)
... get e-mail notifications As several people asked how to get e-mail notifications when new posti

Interpret Order
Hello all,

I'm wondering if I have this:

Code: $switch = array(
'one' =>

some questions
Hello,

I am looking for the answers for following questions:

1) Does PHP support overl

How to make a input/output field with multiple lines
Hello.
I put a input/output field on the screen but I could not change height of it. I need to

how to remove in php string display
My code is

$message="We're looking at developing our website.";

$body= "

Running External Scripts
I am very new to PHP and am not even sure what I'm asking is possible. I have just installed mediaW

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash