Welcome Guest, Not a member yet? Register   Sign In
Catching database class load error
#1

[eluser]Unknown[/eluser]
Hey, I'm new to CI.
One of my controllers implements REST service, and some of the functions use
$this->load->database();

It seems that when error occurs it calls show_error directly. I tried try-catch
but it doesn't work. The problem is I need to catch it and return an error in
REST api.

How can I do it? The only ways I can think of are:
1. check DB connectivity on the main controller which is bad design (why loading db class if I don't need it, besides it can pass this check and error might occur later)

2. extend CI core database class, overloading it with appropriate throws, which seems a little too much for that purpose only

Any good ideas? maybe manipulating content after show_error is called (in that case I have to determine who called it. is it possible? also sounds like workaround and not good solution)

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB