![]() |
"Singleton" Error Queue?
I was working and thinking, as per usual, and figured it might be a handy thing to implement a type that acted as a singleton where I could put a bunch of non-fatal errors into. This way I can have a stack of debug messages and handle them however I want, without try/except. This is for things like query errors, object initialization faults, and the like. Obviously in a finished product the last thing you want is a die statement triggering, and a client wondering how to get back.
Any suggestions for how I could set an object such as this up? Or should I even use an object? I just came up with this recently, so I figured I'd get input on this. |
You could expand it into, in a general sense, a log/debug type of object which stores (optionally different levels if you like) messages, debug data, 'errors', etc. You could use it with the
set_exception/error_handler functions if you headed more along the errors route. |
I could do the exception handlers, but for things like malformed queries I think that's a bit much. But I also don't know that I want an array of messages stored in the database object itself either. I think I want a little separation there, but I'm not sure how to handle it with a singleton/registry style access method.
|
Perhaps you could try extending the Exception class.
|
I could. Though then I'd have to have an error container, override the exception handler and such. Is that better than just making a sort of custom logger?
|
1 Attachment(s)
Look what I found. I wrote some time ago some sort of logger (for fun, to be honest). You can use it if you find it useful.
|
That looks helpful, thanks Xenon. I'll let you know if I use it.
|
| All times are GMT. The time now is 04:04 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0