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

Warning: session_start() headers already sent error - Driving me Nuts!
I am trying my sister in laws site and I keep getting an error with my coding. I am more of a design

having a small php error tha deals with the 'foreach'
Last night i was working on a script for a cart and it seemed to working good, until this morning. F

Images in email problem
I found this script for sending emails, it works but if the email has <img src="image.jp

getAlexaRank($url) function not working
I have made a function to get alexa rank
the site is here: http://mytestsite.rack111.com/1

Do not allow posting of whitespace
Currently the script below works if the user does not type a name/message, but if i create a whitesp

Select all entries from database that include a phrase
I have a database of clubs - one of the categories is meeting time and place
I would like to have

GET vs SUBMIT Button to show sections on one index.php page?
Just curious if one of these ways is better (i.e. more efficient) than the other.

I have a

How to display objects in a row
I have 7 codes that i want to display in a row one next to another.
The first is {$ads->ad

Drop Down and text box issue
Is it possible to set a drop down list and text boxes to a certain width?

here is my code

Getting the full city list from maxminds geoip database
I am suprised I can't find any references to this.

I have maxminds geoip lite installed and i

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