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?

94 Like 49 Dislike
Previous php-forum Next php-forum
Other php-forum

Call db table from any PHP file
Hi,

I want to be able to call a database table that will be setup in another file called init

Variable passed to each() is not an array or object
Hi,

This is a email a friend type of form, and it isn't working anymore.

<?

Displaying values from a SQL count...
Hi,
Easy enough question i just forget the exact method ..
I have ...

Code: //count win

Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system

Say I go to h

Having a problem get the selected item from a drop down menu
I have been looking at this for days now.

I have a drop down menu that get it's values from a

Setting/Modify Headers using mail() function
I have a question about setting email headers when using mail() in a php script.

When I send

PHP header help!
Hi all I am trying to get this php page to refresh every 5 seconds on my phone which is an aastra 48

Need help adding a timestamp to my filename/variable
Hello,

I'm kind of stupid when it comes to php and I need a tiny bit of help. I've got a f

Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like

do while conditions
i want to display 6 images in a 2x3 table
now what would be the correct logic to
count that th

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