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:


Did you know?Explore Trending and Topic pages for more stories like 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

output_buffering so rewrite
I'm planning to rewrite some of my scripts so they don't have to use output buffering to accomplish

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

Passing vars to the DB
I have 3 small testing tables:

ID TYPE
1 pepperoni
2 C. bacon
3 taco

ID TY

explode() function problem maybe
Hi I'm having trouble searching my database. When I type two words in the search field it only searc

Line break?
Hi, I'm new to the forum and new to php. I'm not sure if I'm using the correct terminology so here i

Looking for help reading a .txt or .ini file and outputting the info.
I have a file called Info.ini and It has the following info:
Code: [General]
Online=0
I wou

date("now") prints out wrong date ?
Hi Guys
Anyone know why and how I can fix it ?

getting Vars to pass to next page.
Hello all,
I have a confusing situation on my hands, i am a member of a gaming community and we

What are causes of a connection-timeout with fopen()?
Hello! Here is the situation: The server I host my website on just upgraded it's PHP build from 4.4.

How to sum these output values
Hi

I need sum the month totals
SELECT region_name, area_name ,SUM (CASE WHEN S

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