Where to put custom database error messages

75 views
Skip to first unread message

Jeremy Proffitt

unread,
Dec 5, 2013, 10:43:29 AM12/5/13
to joomla-dev...@googlegroups.com
I was wondering if anyone can point out what is necessary to catch the RuntimeExceptions that are thrown by the DatabaseDriver. I'm trying to try/catch insertObject() and updateObject() calls, but I can't seem to find any point in the code to catch the RuntimeException without going all the way down into the MySQLIDriver. Any pointers would be appreciated.

Thanks!

Michael Babker

unread,
Dec 5, 2013, 11:07:29 AM12/5/13
to joomla-dev...@googlegroups.com
This is good enough for you:
 
try {
    $db->insertObject();
} catch (RuntimeException $e) {
    // Error handling
}


On Thu, Dec 5, 2013 at 9:43 AM, Jeremy Proffitt <jpro...@ezodesign.com> wrote:
I was wondering if anyone can point out what is necessary to catch the RuntimeExceptions that are thrown by the DatabaseDriver. I'm trying to try/catch insertObject() and updateObject() calls, but I can't seem to find any point in the code to catch the RuntimeException without going all the way down into the MySQLIDriver. Any pointers would be appreciated.

Thanks!

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-frame...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.

Jeremy Proffitt

unread,
Dec 5, 2013, 11:17:42 AM12/5/13
to joomla-dev...@googlegroups.com
Unfortunately this was the first thing I tried. It doesn't seem to stop at the catch under any circumstance. The app that I built used JIssues as a reference, and so maintains a lot of the application file methodology, but I'm actually making those calls by using the command line code as an api. API method with insertObject call is being made statically from the controller after a form submit.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsub...@googlegroups.com.

Jeremy Proffitt

unread,
Dec 5, 2013, 11:40:05 AM12/5/13
to joomla-dev...@googlegroups.com
Update: Using the cli directly produces the same result. Any code in the try after the db call, and the catch are ignored.

Al Warren

unread,
Dec 7, 2013, 11:55:23 AM12/7/13
to joomla-dev...@googlegroups.com
Have you tried \RuntimeException ?
Message has been deleted

Jeremy Proffitt

unread,
Dec 7, 2013, 2:20:02 PM12/7/13
to joomla-dev...@googlegroups.com
Al - Turns out I actually had not tried your suggestion in my cli code. That works. Thanks. Now to create a structure to bubble a more friendly user error to the web app.


On Saturday, December 7, 2013 12:35:11 PM UTC-5, Jeremy Proffitt wrote:
I did. Testing a boolean false response from insertObject() doesn’t stop the processing either, regardless of the use of the web app or cli. 

Jeremy Proffitt
Principal, Ezodesign

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to a topic in the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/joomla-dev-framework/03AnAN0Sc-w/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to joomla-dev-framework+unsub...@googlegroups.com.

piotr_cz

unread,
Dec 9, 2013, 6:49:43 AM12/9/13
to joomla-dev...@googlegroups.com
As for bubling:

I decided to catch all (Database) Exceptions at the Application level, in the doExecute method.

Probably you can't use it for every project, but I didn't see much sense in catching an exception in ie. Model just to throw it again.

When application is in debug mode, it prints exception on screen and when not, it's being logged.
Additionally when setting up LoggerServiceProvider I set the logger in DatabaseDriver instance.
Reply all
Reply to author
Forward
0 new messages