Reputation: 92601
I was wondering how would one go about writing custom exception handlers.
so that I can do something like
throw new dbException($sql, $message);
and have it output
There was an error in your query Message: {$message here}
Query: {$sql here}
Line: {line exception was thrown on}
File: {file exception was thrown from}
but I also want to to catch eg syntax errors and parse errors (if possible)
Upvotes: 6
Views: 15955
Reputation:
Why don't use just write your own exception class derived from the standard base exception? See extending exceptions manual.
Upvotes: 1
Reputation: 8344
Unless I am misunderstanding your question, you should be able to extend PHP's Exception
class.
Upvotes: 2
Reputation: 382746
Well, you can extend the Exception
class however you like. For custom exceptions, you might want to check out the post:
You should also find this thread useful:
Upvotes: 10