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

Export hangs
Hi all, please help

I have a Oracle 10.2.0.3.0 database. When I want to query the dba_segmen

$_POST
Hi, I have 2 seperate php files, and i want my $_POSt["fname"] To go into both of them, Fo

Converting from one format to another
"I have got a date in DD/MM/YYYY but I need it in MM-DD-YYYY. Help!"

Get content from table into a list, without repeating.
Alright this is kinda an odd thing, so I need some help.

I have a table "quote" wit

Limiting uploaded file type
I am working on a simple upload script, and I need it to limit the allowed file type that is uploade

simple script won't work. Please help
I'm new to php, and I am having trouble displaying a simple script in my web browser. My php code ex

foreach iterator
Hi Guys
Does the foreach loop have an inbuilt iterator ?

Creating XML with php
I need to creat an XML with php and have successfully produced a valid output.
The problem I hav

error help - Dynamic Image
I've been working on making my site less cluttered in the directories and more secure lately. In an

help with database debug pls
Parse error: syntax error, unexpected T_ELSE in /home/content/m/e/s/mesick/html/students/05/php/chec

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